How to use the iredis.exceptions.InvalidArguments 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 / utils.py View on Github external
"""
    Split Redis command text into command and args.

    :param command: redis command string, with args
    :param all_commands: full redis commands list
    """
    command = command.lstrip()
    upper_raw_command = command.upper()
    for command_name in all_commands:
        if upper_raw_command.startswith(command_name):
            name_len = len(command_name)
            input_command = command[:name_len]
            input_args = command[name_len:]
            break
    else:
        raise InvalidArguments(f"`{command}` is not a valide Redis Command")

    args = list(_strip_quote_args(input_args))

    logger.debug(f"[Utils split command] Command: {input_command} Args: {args}")
    return input_command, args
github laixintao / iredis / iredis / processors.py View on Github external
def apply_transformation(
        self, transformation_input: TransformationInput
    ) -> Transformation:
        input_text = transformation_input.document.text
        if input_text != self.last_text:
            try:
                command, _ = split_command_args(input_text, all_commands)
            except InvalidArguments:
                self.command_holder.command = None
            else:
                self.command_holder.command = command.upper()

            self.last_text = input_text
        return Transformation(transformation_input.fragments)
github laixintao / iredis / iredis / utils.py View on Github external
word = []
            # open quotes
            elif char in ["'", '"']:
                in_quote = char
            else:
                word.append(char)
        if char == "\\" and not pre_back_slash:
            pre_back_slash = True
        else:
            pre_back_slash = False

    if word:
        yield "".join(word)
    # quote not close
    if in_quote:
        raise InvalidArguments("Invalid argument(s)")