We can now use _append suffix un conf.py to append a value to a default configuration instead of reapeating whole configuration
This commit is contained in:
parent
1f6154107c
commit
bca4b8661e
21
iwla.py
21
iwla.py
|
@ -34,9 +34,7 @@ from calendar import monthrange
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
|
|
||||||
import default_conf as conf
|
import default_conf as conf
|
||||||
import conf as _
|
import conf as user_conf
|
||||||
conf.__dict__.update(_.__dict__)
|
|
||||||
del _
|
|
||||||
|
|
||||||
from iplugin import *
|
from iplugin import *
|
||||||
from display import *
|
from display import *
|
||||||
|
@ -735,6 +733,23 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# Load user conf
|
||||||
|
for (k,v) in user_conf.__dict__.items():
|
||||||
|
if k.endswith('_append'):
|
||||||
|
new_k = k[:-7]
|
||||||
|
if new_k in dir(conf):
|
||||||
|
if type(conf.__dict__[new_k]) == list:
|
||||||
|
if type(v) == list:
|
||||||
|
conf.__dict__[new_k] += v
|
||||||
|
else:
|
||||||
|
conf.__dict__[new_k].append(v)
|
||||||
|
else:
|
||||||
|
self.logger.error("%s is not a list" % (new_k))
|
||||||
|
else:
|
||||||
|
self.logger.error("%s doesn't exists in default conf" % (new_k))
|
||||||
|
else:
|
||||||
|
conf.__dict__.update({k:v})
|
||||||
|
|
||||||
if args.clean_output:
|
if args.clean_output:
|
||||||
if os.path.exists(conf.DB_ROOT): shutil.rmtree(conf.DB_ROOT)
|
if os.path.exists(conf.DB_ROOT): shutil.rmtree(conf.DB_ROOT)
|
||||||
if os.path.exists(conf.DISPLAY_ROOT): shutil.rmtree(conf.DISPLAY_ROOT)
|
if os.path.exists(conf.DISPLAY_ROOT): shutil.rmtree(conf.DISPLAY_ROOT)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user