本文整理汇总了Python中quodlibet.util.dprint.Colorise类的典型用法代码示例。如果您正苦于以下问题:Python Colorise类的具体用法?Python Colorise怎么用?Python Colorise使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Colorise类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print_table
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: printErrors
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: bin_debug
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: printErrorList
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: __init__
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: _red
def _red(cls, text):
from quodlibet.util.dprint import Colorise
return Colorise.red(text) if cls.use_colors else text
示例7: addFailure
def addFailure(self, test, err):
unittest.TestResult.addFailure(self, test, err)
print_(Colorise.red(self.CHAR_FAILURE), end="")
示例8: addError
def addError(self, test, err):
unittest.TestResult.addError(self, test, err)
print_(Colorise.red(self.CHAR_ERROR), end="")
示例9: addSuccess
def addSuccess(self, test):
unittest.TestResult.addSuccess(self, test)
print_(Colorise.green(self.CHAR_SUCCESS), end="")