Remove 'groups' top level
Signed-off-by: Andreas Schmidt <mail@schmidt-andreas.de>
This commit is contained in:
parent
6395f2fce6
commit
887968ae85
|
@ -41,20 +41,6 @@ def read_config(config_file):
|
||||||
reader = ConfigReader(config_file)
|
reader = ConfigReader(config_file)
|
||||||
return reader.get_config()
|
return reader.get_config()
|
||||||
|
|
||||||
def precheck_tasks(log, tasks):
|
|
||||||
if isinstance(tasks, dict):
|
|
||||||
if not 'groups' in tasks:
|
|
||||||
raise ReadingError(
|
|
||||||
'Configuration file must contains the structure with the name "groups"')
|
|
||||||
groups = tasks['groups']
|
|
||||||
if not isinstance(groups, dict):
|
|
||||||
raise ReadingError('The groups structure has to have group names')
|
|
||||||
for group in groups:
|
|
||||||
if not isinstance(groups[group], list):
|
|
||||||
raise ReadingError('The group %s mast contains a list of tasks' % group)
|
|
||||||
elif not isinstance(tasks, list):
|
|
||||||
raise ReadingError('Configuration file must be a list of tasks')
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
log = Messenger()
|
log = Messenger()
|
||||||
try:
|
try:
|
||||||
|
@ -91,7 +77,12 @@ def main():
|
||||||
if tasks is None:
|
if tasks is None:
|
||||||
log.warning('Configuration file is empty, no work to do')
|
log.warning('Configuration file is empty, no work to do')
|
||||||
tasks = []
|
tasks = []
|
||||||
precheck_tasks(log, tasks)
|
if isinstance(tasks, dict):
|
||||||
|
for group in tasks:
|
||||||
|
if not isinstance(tasks[group], list):
|
||||||
|
raise ReadingError('The group %s mast contains a list of tasks' % group)
|
||||||
|
elif not isinstance(tasks, list):
|
||||||
|
raise ReadingError('Configuration file must be a list of tasks')
|
||||||
if options.base_directory:
|
if options.base_directory:
|
||||||
base_directory = os.path.abspath(options.base_directory)
|
base_directory = os.path.abspath(options.base_directory)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -20,8 +20,8 @@ class Dispatcher(object):
|
||||||
|
|
||||||
def dispatch(self, tasks):
|
def dispatch(self, tasks):
|
||||||
success = True
|
success = True
|
||||||
if 'groups' in tasks:
|
if isinstance(tasks, dict):
|
||||||
success &= self._handle_groups(tasks['groups'])
|
success &= self._handle_groups(tasks)
|
||||||
else:
|
else:
|
||||||
success &= self._handle_tasks(tasks)
|
success &= self._handle_tasks(tasks)
|
||||||
return success
|
return success
|
||||||
|
|
Loading…
Reference in a new issue