示例#1
0
def print_d(string, context=""):
    """Print debugging information."""
    if quodlibet.const.DEBUG:
        output = sys.stderr
    else:
        output = None

    context = extract_caller_info()
    # strip the package name
    if context.startswith("quodlibet.") and context.count(".") > 1:
        context = context[10:]

    timestr = ("%0.2f" % time.time())[-6:]

    # Translators: "D" as in "Debug". It is prepended to
    # terminal output. APT uses a similar output format.
    prefix = _("D: ")

    string = "%s: %s: %s" % (Colorise.magenta(timestr),
                             Colorise.blue(context), string)
    string = _format_print(string, Colorise.green(prefix))

    if output is not None:
        _print(string, output)

    # Translators: Name of the debug tab in the Output Log window
    quodlibet.util.logging.log(clicolor.strip_color(string), _("Debug"))
示例#2
0
def print_d(string, context=""):
    """Print debugging information."""
    if quodlibet.const.DEBUG:
        output = sys.stderr
    else:
        output = None

    context = extract_caller_info()
    # strip the package name
    if context.startswith("quodlibet.") and context.count(".") > 1:
        context = context[10:]

    timestr = ("%0.2f" % time.time())[-6:]

    # Translators: "D" as in "Debug". It is prepended to
    # terminal output. APT uses a similar output format.
    prefix = _("D:") + " "

    string = "%s: %s: %s" % (Colorise.magenta(timestr),
                             Colorise.blue(context), string)
    string = _format_print(string, Colorise.green(prefix))

    if output is not None:
        _print(string, output)

    # Translators: Name of the debug tab in the Output Log window
    quodlibet.util.logging.log(clicolor.strip_color(string), "debug")
示例#3
0
def _print(string, output, frm="utf-8", strip_color=True, end=os.linesep):
    if is_py2exe() and not is_py2exe_console():
        return

    can_have_color = True
    if strip_color and not output.isatty():
        string = clicolor.strip_color(string)
        can_have_color = False

    if not PY2:
        # FIXME: PY3PORT
        can_have_color = False

    if isinstance(string, text_type):
        string = string.encode(_ENCODING, "replace")
    else:
        string = string.decode(frm).encode(_ENCODING, "replace")

    if isinstance(end, text_type):
        end = end.encode(_ENCODING, "replace")

    assert isinstance(string, bytes)
    assert isinstance(end, bytes)

    try:
        if can_have_color:
            clicolor.print_color(string, output)
        else:
            output.write(string)
        output.write(end)
    except IOError:
        pass
示例#4
0
def print_e(string, context=None):
    """Print errors."""
    # Translators: "E" as in "Error". It is prepended to
    # terminal output. APT uses a similar output format.
    prefix = _("E:") + " "

    string = _format_print(string, Colorise.red(prefix))
    _print(string, sys.stderr)

    # Translators: Name of the warnings tab in the Output Log window
    quodlibet.util.logging.log(clicolor.strip_color(string), "errors")
示例#5
0
def print_e(string, context=None):
    """Print errors."""
    # Translators: "E" as in "Error". It is prepended to
    # terminal output. APT uses a similar output format.
    prefix = _("E: ")

    string = _format_print(string, Colorise.red(prefix))
    _print(string, sys.stderr)

    # Translators: Name of the warnings tab in the Output Log window
    quodlibet.util.logging.log(clicolor.strip_color(string), _("Errors"))
示例#6
0
def print_w(string):
    """Print warnings."""
    # Translators: "W" as in "Warning". It is prepended to
    # terminal output. APT uses a similar output format.
    prefix = _("W:") + " "

    string = _format_print(string, Colorise.red(prefix))
    _print(string, sys.stderr)

    # Translators: Name of the warnings tab in the Output Log window
    quodlibet.util.logging.log(clicolor.strip_color(string), "warnings")
示例#7
0
def print_w(string):
    """Print warnings."""
    # Translators: "W" as in "Warning". It is prepended to
    # terminal output. APT uses a similar output format.
    prefix = _("W:") + " "

    string = _format_print(string, Colorise.red(prefix))
    if PY2:
        _print(string, sys.stderr)
    else:
        _print(string, sys.stderr.buffer)

    # Translators: Name of the warnings tab in the Output Log window
    quodlibet.util.logging.log(clicolor.strip_color(string), "warnings")
示例#8
0
def _print(string, output, frm="utf-8", strip_color=True, end=os.linesep):
    if is_py2exe() and not is_py2exe_console():
        return

    can_have_color = True
    if strip_color and not output.isatty():
        string = clicolor.strip_color(string)
        can_have_color = False

    if isinstance(string, unicode):
        string = string.encode(_ENCODING, "replace")
    else:
        string = string.decode(frm).encode(_ENCODING, "replace")

    try:
        if can_have_color:
            clicolor.print_color(string, output)
        else:
            output.write(string)
        output.write(end)
    except IOError:
        pass
示例#9
0
def _print(string, output, frm="utf-8", strip_color=True, end=os.linesep):
    if _is_py2exe() and not _is_py2exe_console():
        return

    can_have_color = True
    if strip_color and not output.isatty():
        string = clicolor.strip_color(string)
        can_have_color = False

    if isinstance(string, unicode):
        string = string.encode(ENCODING, "replace")
    else:
        string = string.decode(frm).encode(ENCODING, "replace")

    try:
        if can_have_color:
            clicolor.print_color(string, output)
        else:
            output.write(string)
        output.write(end)
    except IOError:
        pass