provide warning if config items will not preserve order

If a group of items are enclosed in {}, then that will be a Python set,
which does not preserve order.  To preserve order, the data must be either
a tuple () or list [].
This commit is contained in:
Hans-Christoph Steiner 2017-02-24 10:28:00 +01:00
parent 388c336e76
commit 4e39621601
2 changed files with 7 additions and 1 deletions

View file

@ -221,6 +221,12 @@ def read_config(opts, config_file='config.py'):
logging.critical("Missing config file - is this a repo directory?")
sys.exit(2)
for k in ('mirrors', 'install_list', 'uninstall_list', 'serverwebroot', 'servergitroot'):
if k in config:
if not type(config[k]) in (str, list, tuple):
logging.warn('"' + k + '" will be in random order!'
+ ' Use () or [] brackets if order is important!')
# smartcardoptions must be a list since its command line args for Popen
if 'smartcardoptions' in config:
config['smartcardoptions'] = config['smartcardoptions'].split(' ')