Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,34 @@
|
|||
def readconf(fn):
|
||||
ret = {}
|
||||
with file(fn) as fp:
|
||||
for line in fp:
|
||||
# Assume whitespace is ignorable
|
||||
line = line.strip()
|
||||
if not line or line.startswith('#'): continue
|
||||
|
||||
boolval = True
|
||||
# Assume leading ";" means a false boolean
|
||||
if line.startswith(';'):
|
||||
# Remove one or more leading semicolons
|
||||
line = line.lstrip(';')
|
||||
# If more than just one word, not a valid boolean
|
||||
if len(line.split()) != 1: continue
|
||||
boolval = False
|
||||
|
||||
bits = line.split(None, 1)
|
||||
if len(bits) == 1:
|
||||
# Assume booleans are just one standalone word
|
||||
k = bits[0]
|
||||
v = boolval
|
||||
else:
|
||||
# Assume more than one word is a string value
|
||||
k, v = bits
|
||||
ret[k.lower()] = v
|
||||
return ret
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
conf = readconf(sys.argv[1])
|
||||
for k, v in sorted(conf.items()):
|
||||
print k, '=', v
|
||||
Loading…
Add table
Add a link
Reference in a new issue