mirror of
https://github.com/EDCD/EDDN.git
synced 2026-11-22 01:46:44 +03:00
This is slightly horrid, but parse the commandline in Settings to
determine if we need to override our configuration.
This commit is contained in:
1 parent
f178fec08d
commit
d71469c10f
1 file changed
+11
-1
@@ -5,6 +5,7 @@ Created on 15 Nov 2014
|
||||
'''
|
||||
|
||||
import simplejson
|
||||
import argparse
|
||||
from eddn import __version__ as version
|
||||
|
||||
|
||||
@@ -38,8 +39,17 @@ class _Settings(object):
|
||||
def loadFrom(self, fileName):
|
||||
f = open(fileName, 'r')
|
||||
conf = simplejson.load(f)
|
||||
for key, value in conf:
|
||||
for key, value in conf.iteritems():
|
||||
if key in self.__dict__:
|
||||
self.__dict__[key] = value
|
||||
else:
|
||||
print "Ignoring unknown setting {0}".format(key)
|
||||
|
||||
Settings = _Settings()
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-c", "--config", nargs="?", default=None)
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.config:
|
||||
Settings.loadFrom(args.config)
|
||||
Reference in new issue
Block a user