#!/usr/bin/env python # -*- coding: utf-8 -*- # import os from unittest.output import termcolors, coverage_output from unittest.output import STATUS_COLORS, STATUS_UNKNOWN from unittest.jsonlog import lib_coverage, status_doc, status_git, status_lib_unittest, status_spec, versions_module STATUS_LENGTH = 13 def status_output(status_or_text, default_color=STATUS_COLORS[STATUS_UNKNOWN]): if status_or_text in STATUS_COLORS: default_color = STATUS_COLORS[status_or_text] return default_color + (STATUS_LENGTH - len(status_or_text[:STATUS_LENGTH])) * ' ' + status_or_text[:STATUS_LENGTH] + termcolors.ENDC def module_status_head(): rv = termcolors.BOLD + termcolors.UNDERLINE + 'Status of the unittests for pylibs:\n' + termcolors.ENDC LINE_FORMAT = '%25s%' + str(STATUS_LENGTH) + 's%' + str(STATUS_LENGTH) + 's%' + str(STATUS_LENGTH) + 's%' + str(STATUS_LENGTH) + 's%' + str(STATUS_LENGTH) + 's%' + str(STATUS_LENGTH) + 's\n' rv += termcolors.BOLD + termcolors.HEADER + LINE_FORMAT % ( 'Library', 'UT-Status', 'DOC-Status', 'Versions', 'UT-Coverage', 'SPEC-Status', 'GIT-Status', ) rv += (25 + 6 * STATUS_LENGTH) * '-' + '\n' + termcolors.ENDC return rv def module_status_line(ut_folder): rv = '%25s%s%s%s%s%s%s\n' % ( os.path.basename(ut_folder) + ':', status_output(status_lib_unittest(ut_folder)), status_output(status_doc(ut_folder)), status_output(versions_module(ut_folder), termcolors.BOLD), coverage_output(*lib_coverage(ut_folder), length=STATUS_LENGTH), status_output(status_spec(ut_folder)), status_output(status_git(ut_folder)), ) return rv