[core/config] Ignore malformed parameters

This commit is contained in:
tobi-wan-kenobi 2020-04-08 11:50:00 +02:00
parent f22561cf90
commit 20044762af

View file

@ -1,8 +1,11 @@
import argparse import argparse
import logging
import util.store import util.store
import util.format import util.format
log = logging.getLogger(__name__)
MODULE_HELP = 'Specify a space-separated list of modules to load. The order of the list determines their order in the i3bar (from left to right). Use <module>:<alias> to provide an alias in case you want to load the same module multiple times, but specify different parameters.' MODULE_HELP = 'Specify a space-separated list of modules to load. The order of the list determines their order in the i3bar (from left to right). Use <module>:<alias> to provide an alias in case you want to load the same module multiple times, but specify different parameters.'
PARAMETER_HELP = 'Provide configuration parameters in the form of <module>.<key>=<value>' PARAMETER_HELP = 'Provide configuration parameters in the form of <module>.<key>=<value>'
THEME_HELP = 'Specify the theme to use for drawing modules' THEME_HELP = 'Specify the theme to use for drawing modules'
@ -27,6 +30,9 @@ class Config(util.store.Store):
parameters = [ item for sub in self.__args.parameters for item in sub ] parameters = [ item for sub in self.__args.parameters for item in sub ]
for param in parameters: for param in parameters:
if not '=' in param:
log.error('missing value for parameter "{}" - ignoring this parameter'.format(param))
continue
key, value = param.split('=', 1) key, value = param.split('=', 1)
self.set(key, value) self.set(key, value)