mirror of
1
0
Fork 0

Remove 'groups' top level

Signed-off-by: Andreas Schmidt <mail@schmidt-andreas.de>
This commit is contained in:
Andreas Schmidt 2020-07-16 14:45:03 +02:00
parent 6395f2fce6
commit 887968ae85
No known key found for this signature in database
GPG Key ID: FEE0A611BEA6DEA0
2 changed files with 8 additions and 17 deletions

View File

@ -41,20 +41,6 @@ def read_config(config_file):
reader = ConfigReader(config_file)
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():
log = Messenger()
try:
@ -91,7 +77,12 @@ def main():
if tasks is None:
log.warning('Configuration file is empty, no work to do')
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:
base_directory = os.path.abspath(options.base_directory)
else:

View File

@ -20,8 +20,8 @@ class Dispatcher(object):
def dispatch(self, tasks):
success = True
if 'groups' in tasks:
success &= self._handle_groups(tasks['groups'])
if isinstance(tasks, dict):
success &= self._handle_groups(tasks)
else:
success &= self._handle_tasks(tasks)
return success