예제 #1
0
def print_table(rows, headers, nicks, order):
    """Print a fancy table"""

    rows.insert(0, headers)
    rows = filter_table(rows, nicks, order)
    if not rows:
        return

    widths = []
    for c in range(len(rows[0])):
        widths.append(max(map(lambda r: len(r[c]), rows)))

    seperator = " %s " % Colorise.gray("|")
    format_string = seperator.join(["%%-%ds" % w for w in widths])

    header = []
    for i, h in enumerate(rows.pop(0)):
        header.append(h.ljust(widths[i], " "))
    line_width = len("   ".join(header)) + 2
    header = [Colorise.bold(h) for h in header]
    header_line = " " + (" %s " % Colorise.gray("|")).join(header)

    print_(header_line.rstrip())
    print_(Colorise.gray("-" * line_width))

    for row in rows:
        print_(" " + (format_string % tuple(row)).rstrip())
예제 #2
0
 def printErrors(self):
     succ = self.testsRun - (len(self.errors) + len(self.failures))
     v = Colorise.bold("%3d" % succ)
     cv = Colorise.green(v) if succ == self.testsRun else Colorise.red(v)
     count = self.TEST_RESULTS_WIDTH - self.testsRun
     print_((" " * count) + cv)
     self.printErrorList('ERROR', self.errors)
     self.printErrorList('FAIL', self.failures)
예제 #3
0
def bin_debug(elements, depth=0, lines=None):
    """Takes a list of gst.Element that are part of a prerolled pipeline, and
    recursively gets the children and all caps between the elements.

    Returns a list of text lines suitable for printing.
    """

    from quodlibet.util.dprint import Colorise

    if lines is None:
        lines = []
    else:
        lines.append(" " * (depth - 1) + "\\")

    for i, elm in enumerate(elements):
        for pad in iter_to_list(elm.iterate_sink_pads):
            caps = pad.get_current_caps()
            if caps:
                lines.append("%s| %s" % (" " * depth, caps.to_string()))
        name = elm.get_name()
        cls = Colorise.blue(type(elm).__name__.split(".", 1)[-1])
        lines.append("%s|-%s (%s)" % (" " * depth, cls, name))

        if isinstance(elm, Gst.Bin):
            children = reversed(iter_to_list(elm.iterate_sorted))
            bin_debug(children, depth + 1, lines)

    return lines
예제 #4
0
 def printErrorList(self, flavour, errors):
     for test, err in errors:
         print_(self.MAJOR_SEPARATOR)
         print_(Colorise.red("%s: %s" % (flavour, str(test))))
         print_(self.MINOR_SEPARATOR)
         # tracebacks can contain encoded paths, not sure
         # what the right fix is here, so use repr
         for line in err.splitlines():
             print_(repr(line)[1:-1])
예제 #5
0
 def __init__(self, test_name, num_tests, out=sys.stdout, failfast=False):
     super(Result, self).__init__()
     self.out = out
     self.failfast = failfast
     if hasattr(out, "flush"):
         out.flush()
     pref = "%s (%d): " % (Colorise.bold(test_name), num_tests)
     line = pref + " " * (self.TEST_NAME_WIDTH - len(test_name) - 7 - int(num_tests and log(num_tests, 10) or 0))
     print_(line, end="")
예제 #6
0
 def _red(cls, text):
     from quodlibet.util.dprint import Colorise
     return Colorise.red(text) if cls.use_colors else text
예제 #7
0
 def addFailure(self, test, err):
     unittest.TestResult.addFailure(self, test, err)
     print_(Colorise.red(self.CHAR_FAILURE), end="")
예제 #8
0
 def addError(self, test, err):
     unittest.TestResult.addError(self, test, err)
     print_(Colorise.red(self.CHAR_ERROR), end="")
예제 #9
0
 def addSuccess(self, test):
     unittest.TestResult.addSuccess(self, test)
     print_(Colorise.green(self.CHAR_SUCCESS), end="")
예제 #10
0
 def addError(self, test, err):
     unittest.TestResult.addError(self, test, err)
     print_(Colorise.red(self.CHAR_ERROR), end="")
예제 #11
0
 def addSuccess(self, test):
     unittest.TestResult.addSuccess(self, test)
     print_(Colorise.green(self.CHAR_SUCCESS), end="")
예제 #12
0
 def addFailure(self, test, err):
     unittest.TestResult.addFailure(self, test, err)
     print_(Colorise.red(self.CHAR_FAILURE), end="")
예제 #13
0
파일: tests.py 프로젝트: qwence/quodlibet
 def _red(cls, text):
     from quodlibet.util.dprint import Colorise
     return Colorise.red(text) if cls.use_colors else text