def format_class_coverage(self, cover_character, klass, space1, progress, coverage, space2, lines, cover_threshold): '''Accepts coverage data for a class and returns a formatted string (intended for humans). ''' # FIXME: # Doesn't this *actually* print coverage for a module, and not a class? # preprocess raw data... klass = klass.lstrip('.') klass = blue(klass) MET_THRESHOLD = coverage >= cover_threshold coverage = '{prefix}{coverage:.1%}'.format( prefix=' ' if (coverage > 0.000) else '', coverage=coverage ) if MET_THRESHOLD: coverage = bold(coverage) coverage = white(coverage) # ...then format return ' {0} {klass}{space1}\t{progress}{coverage}{space2} {lines}'.format( # TODO: # * remove manual spacing, use .format() alignment cover_character, klass=klass, space1=space1, progress=dim('•' * progress), coverage=coverage, space2=space2, lines=lines )
def format_overall_coverage(self, cover_character, max_length, progress, total_coverage): """Accepts overall coverage data and returns a formatted string (intended for humans). """ # preprocess raw data overall = blue("OVERALL") overall = bold(overall) space = " " * (max_length - len("OVERALL")) total = "{total_coverage:.1%}".format(total_coverage=total_coverage) total = white(bold(total)) # then format return " {0} {overall}{space}\t{progress} {total}".format( cover_character, overall=overall, space=space, progress="•" * progress, total=total )
def format_class_coverage(self, cover_character, klass, space1, progress, coverage, space2, lines, cover_threshold): '''Accepts coverage data for a class and returns a formatted string (intended for humans). ''' # FIXME: # Doesn't this *actually* print coverage for a module, and not a class? # preprocess raw data... klass = klass.lstrip('.') klass = blue(klass) MET_THRESHOLD = coverage >= cover_threshold coverage = '{prefix}{coverage:.1%}'.format(prefix=' ' if (coverage > 0.000) else '', coverage=coverage) if MET_THRESHOLD: coverage = bold(coverage) coverage = white(coverage) # ...then format return ' {0} {klass}{space1}\t{progress}{coverage}{space2} {lines}'.format( # TODO: # * remove manual spacing, use .format() alignment cover_character, klass=klass, space1=space1, progress=dim('•' * progress), coverage=coverage, space2=space2, lines=lines)
def format_overall_coverage(self, cover_character, max_length, progress, total_coverage): '''Accepts overall coverage data and returns a formatted string (intended for humans). ''' # preprocess raw data overall = blue('OVERALL') overall = bold(overall) space = ' ' * (max_length - len('OVERALL')) total = '{total_coverage:.1%}'.format(total_coverage=total_coverage) total = white(bold(total)) # then format return ' {0} {overall}{space}\t{progress} {total}'.format( cover_character, overall=overall, space=space, progress='•' * progress, total=total)
def header(self, msg, ruler_character='='): '''Returns the string `msg` with a text "ruler". Also colorizes as bright green (when color is available). ''' ruler = ' {0}'.format(len(msg) * ruler_character) msg = ' {0}'.format(msg) msg = '{0}{ruler}{0}{msg}{0}{ruler}{0}'.format('\n', ruler=ruler, msg=msg) msg = green(bold(msg)) return msg
def header(self, msg, ruler_character='='): '''Returns the string `msg` with a text "ruler". Also colorizes as bright green (when color is available). ''' ruler = ' {0}'.format(len(msg) * ruler_character) msg = ' {0}'.format(msg) msg = '{0}{ruler}{0}{msg}{0}{ruler}{0}'.format( '\n', ruler=ruler, msg=msg) msg = green(bold(msg)) return msg