tasks: refacor format_tasks

- add date
- add test-only flag
This commit is contained in:
Ivan A. Melnikov 2019-02-01 20:26:04 +04:00
parent ca22430030
commit 7160cbf06d

View File

@ -102,17 +102,22 @@ def format_subtask(subtask, extra_info=None):
return result
def format_task(info, extra_info=None):
head = '%(taskid)s %(state)s try=%(try)s %(owner)s' % info
_TASK_FORMAT = '%(taskid)-6d [%(task_time)s] %(state)s try=%(try)s %(owner)s%(test_only)s%(deps)s\n%(subtasks)s' # noqa
def format_task(info, extra_info=None):
fmt_args = info.copy()
fmt_args['test_only'] = ' test-only' if info.get('test_only') else ''
depends = sorted(utils.maybe_int(x) for x in info.get('depends', []))
if depends:
head += ' depends=' + ','.join(str(x) for x in depends)
fmt_args['deps'] = ' depends=' + ','.join(str(x) for x in depends)
else:
fmt_args['deps'] = ''
subtasks = sorted((int(k), format_subtask(s, extra_info))
for k, s in info['subtasks'].iteritems())
tail = ''.join('\n%12d %s' % item for item in subtasks)
return head + tail
fmt_args['subtasks'] = '\n'.join('%12d %s' % item for item in subtasks)
return _TASK_FORMAT % fmt_args
def format_tasks_short(tasks, separator=','):