-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathconfig.py
More file actions
20 lines (17 loc) · 725 Bytes
/
config.py
File metadata and controls
20 lines (17 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Copyright (c) 2014-2017 esotericnonsense (Daniel Edgecumbe)
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/licenses/mit-license.php
def parse_file(filename):
with open(filename, "r") as f:
cfg = {}
for line in f:
line = line.strip()
if line and not line.startswith("#"):
try:
# replace maintains compatibility with older config files
(key, value) = line.replace(' = ', '=').split('=', 1)
cfg[key] = value
except ValueError:
# Happens when line has no '=', ignore
pass
return cfg