How to use the iredis.config.config.raw function in iredis

To help you get started, we’ve selected a few iredis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github laixintao / iredis / tests / test_render_functions.py View on Github external
def test_render_members_config_raw(completer):
    completer.completers["members"].words = []
    config.raw = True
    config.withscores = True
    rendered = renders.render_members([b"duck", b"667", b"camel", b"708"], completer)

    assert rendered == b"duck\n667\ncamel\n708"
    assert completer.completers["member"].words == ["camel", "duck"]
github laixintao / iredis / tests / test_commandline.py View on Github external
def test_command_entry_tty(is_tty, raw_arg_is_raw, final_config_is_raw):
    # is tty + raw -> raw
    with patch("sys.stdout.isatty") as patch_tty:
        from iredis.config import config

        patch_tty.return_value = is_tty
        if raw_arg_is_raw is None:
            call = ["iredis"]
        elif raw_arg_is_raw is True:
            call = ["iredis", "--raw"]
        elif raw_arg_is_raw is False:
            call = ["iredis", "--no-raw"]
        else:
            raise Exception()
        gather_args.main(call, standalone_mode=False)
        assert config.raw == final_config_is_raw
github laixintao / iredis / tests / test_render_functions.py View on Github external
def test_render_members(completer):
    completer.completers["members"].words = []
    config.raw = False
    config.withscores = True
    rendered = renders.render_members([b"duck", b"667", b"camel", b"708"], completer)

    assert rendered == FormattedText(
        [
            ("", "1)"),
            ("", " "),
            ("class:integer", "667 "),
            ("class:member", '"duck"'),
            ("", "\n"),
            ("", "2)"),
            ("", " "),
            ("class:integer", "708 "),
            ("class:member", '"camel"'),
        ]
    )
github laixintao / iredis / iredis / entry.py View on Github external
def write_result(text):
    """
    :param text: is_raw: bytes, not raw: FormattedText
    :is_raw: bool
    """
    if config.raw:
        sys.stdout.buffer.write(text)
        sys.stdout.write("\n")
    else:
        print_formatted_text(text, end="", style=STYLE)
        print_formatted_text()
github laixintao / iredis / iredis / entry.py View on Github external
- iredis -h 127.0.0.1 -p 6379 -a 

    Type "help" in interactive mode for information on available commands
    and settings.
    """
    logger.info(
        f"[start args] host={h}, port={p}, db={n}, raw={raw}, cmd={cmd}, decode={decode}."
    )
    # figout raw output or formatted output
    if ctx.get_parameter_source("raw") == click.ParameterSource.COMMANDLINE:
        config.raw = raw
    else:
        if sys.stdout.isatty():
            config.raw = False
        else:
            config.raw = True
    # set config decode
    config.decode = decode
    config.newbie_mode = newbie

    return ctx
github laixintao / iredis / iredis / entry.py View on Github external
- iredis
      - iredis -h 127.0.0.1 -p 6379
      - iredis -h 127.0.0.1 -p 6379 -a 

    Type "help" in interactive mode for information on available commands
    and settings.
    """
    logger.info(
        f"[start args] host={h}, port={p}, db={n}, raw={raw}, cmd={cmd}, decode={decode}."
    )
    # figout raw output or formatted output
    if ctx.get_parameter_source("raw") == click.ParameterSource.COMMANDLINE:
        config.raw = raw
    else:
        if sys.stdout.isatty():
            config.raw = False
        else:
            config.raw = True
    # set config decode
    config.decode = decode
    config.newbie_mode = newbie

    return ctx
github laixintao / iredis / iredis / entry.py View on Github external
\b
    Examples:
      - iredis
      - iredis -h 127.0.0.1 -p 6379
      - iredis -h 127.0.0.1 -p 6379 -a 

    Type "help" in interactive mode for information on available commands
    and settings.
    """
    logger.info(
        f"[start args] host={h}, port={p}, db={n}, raw={raw}, cmd={cmd}, decode={decode}."
    )
    # figout raw output or formatted output
    if ctx.get_parameter_source("raw") == click.ParameterSource.COMMANDLINE:
        config.raw = raw
    else:
        if sys.stdout.isatty():
            config.raw = False
        else:
            config.raw = True
    # set config decode
    config.decode = decode
    config.newbie_mode = newbie

    return ctx
github laixintao / iredis / iredis / renders.py View on Github external
def _render_scan(render_response, response, completer):
    cursor, responses = response
    if config.raw:
        return b"\n".join([cursor, render_response(responses, completer)])

    rendered = [
        ("class:type", "(cursor) "),
        ("class:integer", cursor.decode()),
        ("", "\n"),
    ]
    rendered_keys = render_response(responses, completer)
    return FormattedText(rendered + rendered_keys)