improvement: allow newlines in ENV files (#69)

pull/79/head^2
dWiGhT 2019-08-05 01:08:24 -07:00 zatwierdzone przez Rui Carmo
rodzic 8a45c1af85
commit a5efdf89b5
2 zmienionych plików z 8 dodań i 1 usunięć

Wyświetl plik

@ -1,6 +1,13 @@
# variables are global and can be replaced
SETTING1=True
SETTING2=${SETTING1}/Maybe
# addr:port
PORT=9080
BIND_ADDRESS=0.0.0.0
# the max number the worker will process
RANGE=10
# worker sleep interval between prints
INTERVAL=1

Wyświetl plik

@ -307,7 +307,7 @@ def parse_settings(filename, env={}):
with open(filename, 'r') as settings:
for line in settings:
if '#' == line[0]: # allow for comments
if '#' == line[0] or len(line.strip()) == 0: # ignore comments and newlines
continue
try:
k, v = map(lambda x: x.strip(), line.split("=", 1))