Beispiel #1
0
def _pprint_displayhook(value):
    if value is not None:
        builtins._ = None  # Set '_' to None to avoid recursion
        if HAVE_PYGMENTS:
            s = pretty(value)  # color case
            lexer = pyghooks.XonshLexer()
            tokens = list(pygments.lex(s, lexer=lexer))
            print_color(tokens)
        else:
            pprint(value)  # black & white case
        builtins._ = value
Beispiel #2
0
def _pprint_displayhook(value):
    if value is None or isinstance(value, HiddenCompletedCommand):
        return
    builtins._ = None  # Set '_' to None to avoid recursion
    if HAVE_PYGMENTS:
        s = pretty(value)  # color case
        lexer = pyghooks.XonshLexer()
        tokens = list(pygments.lex(s, lexer=lexer))
        print_color(tokens)
    else:
        pprint(value)  # black & white case
    builtins._ = value
Beispiel #3
0
def _pprint_displayhook(value):
    if value is None or isinstance(value, HiddenCompletedCommand):
        return
    builtins._ = None  # Set '_' to None to avoid recursion
    if HAS_PYGMENTS:
        s = pretty(value)  # color case
        lexer = pyghooks.XonshLexer()
        tokens = list(pygments.lex(s, lexer=lexer))
        print_color(tokens)
    else:
        pprint(value)  # black & white case
    builtins._ = value
Beispiel #4
0
def _pprint_displayhook(value):
    if value is None:
        return
    builtins._ = None  # Set '_' to None to avoid recursion
    if isinstance(value, HiddenCommandPipeline):
        builtins._ = value
        return
    env = builtins.__xonsh_env__
    if env.get('PRETTY_PRINT_RESULTS'):
        printed_val = pretty(value)
    else:
        printed_val = repr(value)
    if HAS_PYGMENTS and env.get('COLOR_RESULTS'):
        tokens = list(pygments.lex(printed_val, lexer=pyghooks.XonshLexer()))
        print_color(tokens)
    else:
        print(printed_val)  # black & white case
    builtins._ = value
Beispiel #5
0
def _pprint_displayhook(value):
    if value is None:
        return
    builtins._ = None  # Set '_' to None to avoid recursion
    if isinstance(value, HiddenCommandPipeline):
        builtins._ = value
        return
    env = builtins.__xonsh_env__
    if env.get('PRETTY_PRINT_RESULTS'):
        printed_val = pretty(value)
    else:
        printed_val = repr(value)
    if HAS_PYGMENTS and env.get('COLOR_RESULTS'):
        tokens = list(pygments.lex(printed_val, lexer=pyghooks.XonshLexer()))
        print_color(tokens)
    else:
        print(printed_val)  # black & white case
    builtins._ = value
Beispiel #6
0
def _pprint_displayhook(value):
    if value is None:
        return
    builtins._ = None  # Set '_' to None to avoid recursion
    if isinstance(value, HiddenCommandPipeline):
        builtins._ = value
        return
    env = builtins.__xonsh__.env
    if env.get("PRETTY_PRINT_RESULTS"):
        printed_val = pretty(value)
    else:
        printed_val = repr(value)
    if HAS_PYGMENTS and env.get("COLOR_RESULTS"):
        tokens = list(pygments.lex(printed_val, lexer=pyghooks.XonshLexer()))
        end = "" if env.get("SHELL_TYPE") == "prompt_toolkit2" else "\n"
        print_color(tokens, end=end)
    else:
        print(printed_val)  # black & white case
    builtins._ = value
Beispiel #7
0
def _pprint_displayhook(value):
    if value is None:
        return
    builtins._ = None  # Set '_' to None to avoid recursion
    if isinstance(value, HiddenCommandPipeline):
        builtins._ = value
        return
    env = builtins.__xonsh__.env
    if env.get("PRETTY_PRINT_RESULTS"):
        printed_val = pretty(value)
    else:
        printed_val = repr(value)
    if HAS_PYGMENTS and env.get("COLOR_RESULTS"):
        tokens = list(pygments.lex(printed_val, lexer=pyghooks.XonshLexer()))
        end = "" if env.get("SHELL_TYPE") == "prompt_toolkit2" else "\n"
        print_color(tokens, end=end)
    else:
        print(printed_val)  # black & white case
    builtins._ = value
Beispiel #8
0
def test_pretty_fn(obj, exp):
    result = pretty.pretty(obj)
    assert result == exp