How to use the iredis.commands_csv_loader.commands_summary 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_utils.py View on Github external
def test_render_bottom_with_command_json():
    for command, info in commands_summary.items():
        print_formatted_text(command_syntax(command, info), style=STYLE)
github laixintao / iredis / iredis / completers.py View on Github external
def get_completer(group2commands, redis_grammar):
    completer_mapping = {}
    # patch command completer with hint
    command_hint = {key: info["summary"] for key, info in commands_summary.items()}
    for command_group, commands in group2commands.items():
        words = commands + [command.lower() for command in commands]
        if config.newbie_mode:
            hint = {command: command_hint.get(command.upper()) for command in words}
        else:
            hint = None
        completer_mapping[command_group] = WordCompleter(
            words, sentence=True, meta_dict=hint
        )

    key_completer = LatestUsedFirstWordCompleter(config.completer_max, [])
    member_completer = LatestUsedFirstWordCompleter(config.completer_max, [])
    field_completer = LatestUsedFirstWordCompleter(config.completer_max, [])
    completer_mapping.update(
        {
            key: WordCompleter(tokens.split(" "), ignore_case=True)
github laixintao / iredis / iredis / bottom.py View on Github external
"class:bottom-toolbar.off",
                f"Loading Redis commands {anim}",
            )
            return [loading_text]
        elif config.compiling == COMPILING_JUST_FINISH:
            loading_text = (
                "class:bottom-toolbar.loaded",
                f"Redis commands loaded! Auto Completer activated!",
            )
            return [loading_text]
        else:
            text = BUTTOM_TEXT
            # add command help if valide
            if self.command_holder.command:
                try:
                    command_info = commands_summary[self.command_holder.command]
                    text = command_syntax(self.command_holder.command, command_info)
                except KeyError:
                    pass
        return text
github laixintao / iredis / iredis / client.py View on Github external
def do_help(self, *args):
        command_docs_name = "-".join(args).lower()
        command_summary_name = " ".join(args).upper()
        try:
            doc_file = open(
                project_path / "redis-doc" / "commands" / f"{command_docs_name}.md"
            )
        except FileNotFoundError:
            raise NotRedisCommand(
                f"{command_summary_name} is not a valide Redis command."
            )

        with doc_file as doc_file:
            doc = doc_file.read()
            rendered_detail = markdown.render(doc)
        summary_dict = commands_summary[command_summary_name]

        avaiable_version = summary_dict.get("since", "?")
        server_version = config.version
        # FIXME anything strange with single quotes?
        logger.debug(f"[--version--] '{server_version}'")
        try:
            is_avaiable = StrictVersion(server_version) > StrictVersion(
                avaiable_version
            )
        except Exception as e:
            logger.exception(e)
            is_avaiable = None

        if is_avaiable:
            avaiable_text = f"(Avaiable on your redis-server: {server_version})"
        elif is_avaiable is False: