How to use the iredis.config.config.compiling 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 / iredis / bottom.py View on Github external
def render(self):
        if config.compiling == COMPILING_IN_PROGRESS:
            anim = self.get_animation_char()
            loading_text = (
                "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 / entry.py View on Github external
def repl(client, session, start_time):
    command_holder = UserInputCommand()
    timer(f"First REPL command enter, time cost: {time.time() - start_time}")

    while True:
        logger.info("↓↓↓↓" * 10)
        logger.info("REPL waiting for command...")
        if config.compiling != COMPILING_DONE:
            # auto refresh to display animation...
            _interval = 0.1
        else:
            _interval = None

        try:
            command = session.prompt(
                "{hostname}> ".format(hostname=str(client)),
                bottom_toolbar=BottomToolbar(command_holder).render,
                refresh_interval=_interval,
                input_processors=[GetCommandProcessor(command_holder)],
                rprompt=lambda: "" if config.transaction else None,
            )

        except KeyboardInterrupt:
            logger.warning("KeyboardInterrupt!")
github laixintao / iredis / iredis / completers.py View on Github external
redis_grammar = compile(REDIS_COMMANDS)
        end_time = time.time()
        logger.debug(f"[compile] Compile finished! Cost: {end_time - start_time}")

        # get lexer
        lexer = get_lexer(group2commands.keys(), redis_grammar)
        # get completer
        completer = get_completer(group2commands, redis_grammar)

        session.completer = completer
        session.lexer = lexer
        logger.debug("[compile] Patch finished!")

        config.compiling = COMPILING_JUST_FINISH
        time.sleep(1)
        config.compiling = COMPILING_DONE
github laixintao / iredis / iredis / completers.py View on Github external
start_time = time.time()
        logger.debug("[compile] start compile grammer...")
        redis_grammar = compile(REDIS_COMMANDS)
        end_time = time.time()
        logger.debug(f"[compile] Compile finished! Cost: {end_time - start_time}")

        # get lexer
        lexer = get_lexer(group2commands.keys(), redis_grammar)
        # get completer
        completer = get_completer(group2commands, redis_grammar)

        session.completer = completer
        session.lexer = lexer
        logger.debug("[compile] Patch finished!")

        config.compiling = COMPILING_JUST_FINISH
        time.sleep(1)
        config.compiling = COMPILING_DONE