diff options
Diffstat (limited to 'iredis')
-rw-r--r-- | iredis/__init__.py | 2 | ||||
-rw-r--r-- | iredis/client.py | 26 | ||||
-rw-r--r-- | iredis/commands.py | 6 | ||||
-rw-r--r-- | iredis/completers.py | 8 | ||||
-rw-r--r-- | iredis/data/commands.json | 6 | ||||
-rw-r--r-- | iredis/data/commands/eval.md | 2 | ||||
-rw-r--r-- | iredis/data/commands/xadd.md | 2 | ||||
-rw-r--r-- | iredis/data/iredisrc | 6 | ||||
-rw-r--r-- | iredis/entry.py | 2 | ||||
-rw-r--r-- | iredis/markdown.py | 37 | ||||
-rw-r--r-- | iredis/redis_grammar.py | 2 | ||||
-rw-r--r-- | iredis/renders.py | 8 | ||||
-rw-r--r-- | iredis/style.py | 4 | ||||
-rw-r--r-- | iredis/utils.py | 2 |
14 files changed, 55 insertions, 58 deletions
diff --git a/iredis/__init__.py b/iredis/__init__.py index fcfdf38..f84c53b 100644 --- a/iredis/__init__.py +++ b/iredis/__init__.py @@ -1 +1 @@ -__version__ = "1.10.0" +__version__ = "1.11.0" diff --git a/iredis/client.py b/iredis/client.py index 2c9bda5..a5295fb 100644 --- a/iredis/client.py +++ b/iredis/client.py @@ -224,7 +224,7 @@ class Client: logger.info( f"execute by connection: connection={connection}, name={command_name}, {args}, {options}" ) - retry_times = config.retry_times # FIXME configureable + retry_times = config.retry_times # FIXME configurable last_error = None need_refresh_connection = False @@ -487,7 +487,7 @@ class Client: """ if command_name.upper() == "HELLO": raise NotSupport("IRedis currently not support RESP3, sorry about that.") - # TRANSATION state chage + # TRANSACTION state change if command_name.upper() in ["EXEC", "DISCARD"]: logger.debug(f"[After hook] Command is {command_name}, unset transaction.") config.transaction = False @@ -527,25 +527,25 @@ class Client: rendered_detail = markdown.render(doc) summary_dict = commands_summary[command_summary_name] - avaiable_version = summary_dict.get("since", "?") + available_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 + is_available = StrictVersion(server_version) > StrictVersion( + available_version ) except Exception as e: logger.exception(e) - is_avaiable = None + is_available = None - if is_avaiable: - avaiable_text = f"(Avaiable on your redis-server: {server_version})" - elif is_avaiable is False: - avaiable_text = f"(Not avaiable on your redis-server: {server_version})" + if is_available: + available_text = f"(Available on your redis-server: {server_version})" + elif is_available is False: + available_text = f"(Not available on your redis-server: {server_version})" else: - avaiable_text = "" - since_text = f"{avaiable_version} {avaiable_text}" + available_text = "" + since_text = f"{available_version} {available_text}" summary = [ ("", "\n"), @@ -658,7 +658,7 @@ class Client: yield FormattedText([("class:dockey", "XINFO: ")]) yield renders.OutputRender.render_list(xinfo) - # incase the result is too long, we yield only once so the outputer + # in case the result is too long, we yield only once so the outputer # can pager it. peek_response = [] key_type = nativestr(self.execute("type", key)) diff --git a/iredis/commands.py b/iredis/commands.py index dcd457f..9f10d53 100644 --- a/iredis/commands.py +++ b/iredis/commands.py @@ -20,7 +20,7 @@ def _load_command_summary(): def _load_command(): """ - load command informations from file. + load command information from file. :returns: - original_commans: dict, command name : Command - command_group: dict, group_name: command_names @@ -115,7 +115,7 @@ def split_command_args(command): command = command.strip() for command_name in all_commands: - # for command that is paritaly inputed, like `command in`, we should + # for command that is paritaly input, like `command in`, we should # match with `command info`, otherwise, `command in` will result in # `command` with `args` is ('in') which is an invalid case. normalized_input_command = " ".join(command.split()).upper() @@ -125,7 +125,7 @@ def split_command_args(command): and command_name != normalized_input_command ): raise AmbiguousCommand("command is not finished") - # allow multiplt space in user inputed command + # allow multiple space in user input command command_allow_multi_spaces = "[ ]+".join(command_name.split()) matcher = re.match(fr"({command_allow_multi_spaces})( |$)", command.upper()) if matcher: diff --git a/iredis/completers.py b/iredis/completers.py index afdc7ef..f5d922e 100644 --- a/iredis/completers.py +++ b/iredis/completers.py @@ -94,8 +94,8 @@ class TimestampCompleter(Completer): return current = int(text) now = pendulum.now() - for unit, minium in self.when_lower_than.items(): - if current <= minium: + for unit, minimum in self.when_lower_than.items(): + if current <= minimum: dt = now.subtract(**{f"{unit}s": current}) meta = f"{text} {unit}{'s' if current > 1 else ''} ago ({dt.format('YYYY-MM-DD HH:mm:ss')})" yield Completion( @@ -205,7 +205,7 @@ class IRedisCompleter(Completer): for _token_in_command in tokens_in_command: # prompt_toolkit didn't support multi tokens # like DEL key1 key2 key3 - # so we have to split them manualy + # so we have to split them manually for single_token in strip_quote_args(_token_in_command): _completer.touch(single_token) @@ -310,7 +310,7 @@ class IRedisCompleter(Completer): "member": member_completer, "members": member_completer, # zmember - # TODO sperate sorted set and set + # TODO separate sorted set and set # hash fields "field": field_completer, "fields": field_completer, diff --git a/iredis/data/commands.json b/iredis/data/commands.json index 1b0ae22..74093cc 100644 --- a/iredis/data/commands.json +++ b/iredis/data/commands.json @@ -2310,7 +2310,7 @@ "WITHVALUES" ], "optional": true - } + } ], "optional": true } @@ -4378,7 +4378,7 @@ "WITHSCORES" ], "optional": true - } + } ], "optional": true } @@ -5048,7 +5048,7 @@ }, "XADD": { "summary": "Appends a new entry to a stream", - "complexity": "O(1) when adding a new entry, O(N) when trimming where N being the number of entires evicted.", + "complexity": "O(1) when adding a new entry, O(N) when trimming where N being the number of entries evicted.", "arguments": [ { "name": "key", diff --git a/iredis/data/commands/eval.md b/iredis/data/commands/eval.md index 3618ac6..f85d727 100644 --- a/iredis/data/commands/eval.md +++ b/iredis/data/commands/eval.md @@ -733,7 +733,7 @@ Valid formats: > - big endian < - little endian ![num] - alignment -x - pading +x - padding b/B - signed/unsigned byte h/H - signed/unsigned short l/L - signed/unsigned long diff --git a/iredis/data/commands/xadd.md b/iredis/data/commands/xadd.md index aca1de7..8a80556 100644 --- a/iredis/data/commands/xadd.md +++ b/iredis/data/commands/xadd.md @@ -52,7 +52,7 @@ to match the one of this other system. documentation page for more information. This allows adding new entries and keeping the stream's size in check with a single call to `XADD`, effectively capping the stream with an arbitrary threshold. Although exact trimming is -possible and is the default, due to the internal representation of steams it is +possible and is the default, due to the internal representation of streams it is more efficient to add an entry and trim stream with `XADD` using **almost exact** trimming (the `~` argument). diff --git a/iredis/data/iredisrc b/iredis/data/iredisrc index 5baef86..bf79e90 100644 --- a/iredis/data/iredisrc +++ b/iredis/data/iredisrc @@ -30,9 +30,9 @@ socket_keepalive = True shell = True # decode redis response, default None -decode = +decode = -# enable pager? defualt to True, you can disable it by changing it to False +# enable pager? default to True, you can disable it by changing it to False enable_pager = True # pager setting when line is too tall @@ -52,7 +52,7 @@ bottom_bar = True warning = True # IRedis log for debugging, leave this blank will disable log. -# You don't need this unless you are debuging iredis. +# You don't need this unless you are debugging iredis. # Be careful this will log your commands input (include AUTH with password) to # log file. # eg. ~/.iredis.log diff --git a/iredis/entry.py b/iredis/entry.py index eb57668..2a9dc05 100644 --- a/iredis/entry.py +++ b/iredis/entry.py @@ -160,7 +160,7 @@ class Rainbow: def prompt_message(client): - # TODO custome prompt + # TODO custom prompt text = "{hostname}> ".format(hostname=str(client)) if config.rainbow: return list(zip(Rainbow(), text)) diff --git a/iredis/markdown.py b/iredis/markdown.py index ff2b726..6f26642 100644 --- a/iredis/markdown.py +++ b/iredis/markdown.py @@ -13,24 +13,24 @@ from prompt_toolkit.formatted_text import to_formatted_text, HTML logger = logging.getLogger(__name__) -class TerminalRender(mistune.Renderer): +class TerminalRender(mistune.HTMLRenderer): def _to_title(self, text): return f"{text}\n{'='*len(text)}\n" def paragraph(self, text): return text + "\n\n" - def block_code(self, code, language=None): + def block_code(self, code, info=None): code = "\n".join([" " + line for line in code.splitlines()]) return super().block_code(code) - def header(self, text, level, raw=None): + def heading(self, text, level): if level == 2: header_text = self._to_title(text) - return super().header(header_text, 2) - return super().header(self._to_title(text), level) + return super().heading(header_text, 2) + return super().heading(self._to_title(text), level) - def list(self, body, ordered=True): + def list(self, body, ordered, level, start=None): """Rendering list tags like ``<ul>`` and ``<ol>``. :param body: body contents of the list. @@ -41,29 +41,26 @@ class TerminalRender(mistune.Renderer): tag = "ol" return "<%s>%s</%s>\n" % (tag, body, tag) - def list_item(self, text): + def list_item(self, text, level): """Rendering list item snippet. Like ``<li>``.""" return "<li> * %s</li>\n" % text -class RedisDocLexer(mistune.BlockLexer): - def enable_at_title(self): - self.rules.at_title = re.compile(r"^@(\w+) *(?:\n+|$)") # @example - self.default_rules.insert(0, "at_title") +renderer = TerminalRender() +markdown_render = mistune.Markdown(renderer) - def parse_at_title(self, m): - text = m.group(1) - self.tokens.append({"type": "heading", "level": 2, "text": text}) +# replace redis doc's title (and following newlines & spaces) +# with markdown's second level title +redisdoc_title_re = re.compile(r"^@(\w+) *(?:\n+|$)") -renderer = TerminalRender() -block_lexer = RedisDocLexer() -block_lexer.enable_at_title() -markdown_render = mistune.Markdown(renderer, block=block_lexer) +def replace_to_markdown_title(original): + replaced = redisdoc_title_re.sub(r"## \g<1>", original) + return replaced def render(text): - html_text = markdown_render(text) + replaced = replace_to_markdown_title(text) + html_text = markdown_render(replaced) logger.debug("[Document] {} ...".format(html_text)[:20]) - return to_formatted_text(HTML(html_text)) diff --git a/iredis/redis_grammar.py b/iredis/redis_grammar.py index e680839..692edc6 100644 --- a/iredis/redis_grammar.py +++ b/iredis/redis_grammar.py @@ -622,7 +622,7 @@ def get_command_grammar(command): syntax = GRAMMAR.get(syntax_name) # If a command is not supported yet, (e.g. command from latest version added - # by Redis recently, or command from third Redis module.) return a defualt + # by Redis recently, or command from third Redis module.) return a default # grammar, so the lexer and completion won't be activated. if syntax is None: return command_grammar diff --git a/iredis/renders.py b/iredis/renders.py index 2898c42..2bb21c9 100644 --- a/iredis/renders.py +++ b/iredis/renders.py @@ -74,8 +74,8 @@ class OutputRender: utf-8 decoded. """ decoded = nativestr(value) - splitted = "\n".join(decoded.splitlines()) # get rid of last newline - return splitted + split = "\n".join(decoded.splitlines()) # get rid of last newline + return split @staticmethod def render_nested_pair(value): @@ -163,7 +163,7 @@ class OutputRender: def render_simple_string(text): """ If response is b'OK', render simple string always with success color. - If Error happend, error will be rendered by ``render_error`` + If Error happens, error will be rendered by ``render_error`` """ if text is None: return NIL @@ -174,7 +174,7 @@ class OutputRender: def render_help(raw): """ render help text message. - the comand like ``ACL HELP`` and ``MEMORY HELP`` + the command like ``ACL HELP`` and ``MEMORY HELP`` will return a list of strings. we render it as plain text """ diff --git a/iredis/style.py b/iredis/style.py index 9fd6eb6..7262072 100644 --- a/iredis/style.py +++ b/iredis/style.py @@ -39,9 +39,9 @@ GROUP = { "group.server": "#E6DB74", "group.set": "#E6DB74", "group.sortedset": "#E6DB74", - "group.stram": "#E6DB74", + "group.stream": "#E6DB74", "group.string": "#E6DB74", - "group.transections": "#E6DB74", + "group.transactions": "#E6DB74", } diff --git a/iredis/utils.py b/iredis/utils.py index b64f874..7cfae5a 100644 --- a/iredis/utils.py +++ b/iredis/utils.py @@ -229,7 +229,7 @@ def ensure_str(origin, decode=None): return origin.decode(decode) return _literal_bytes(origin) else: - raise Exception(f"Unkown type: {type(origin)}, origin: {origin}") + raise Exception(f"Unknown type: {type(origin)}, origin: {origin}") def double_quotes(unquoted): |