From c0ed80e02b7d624bda922914e1aaa61377a89b24 Mon Sep 17 00:00:00 2001 From: Miroslav Date: Sat, 4 Aug 2018 11:56:53 +0300 Subject: [PATCH] Excess changes were canceled --- mitmproxy/command.py | 3 +-- mitmproxy/language/lexer.py | 7 ++----- mitmproxy/language/parser.py | 2 +- mitmproxy/tools/console/consoleaddons.py | 16 ++++++---------- mitmproxy/tools/console/keymap.py | 5 ----- 5 files changed, 10 insertions(+), 23 deletions(-) diff --git a/mitmproxy/command.py b/mitmproxy/command.py index ab6063f99..df32f9fea 100644 --- a/mitmproxy/command.py +++ b/mitmproxy/command.py @@ -221,7 +221,7 @@ class CommandManager(mitmproxy.types._CommandBase): """ Parse a possibly partial command. Return a sequence of ParseResults and a sequence of remainder type help items. """ - parts: typing.List[str] = [t.value for t in lexer.get_tokens(cmdstr)] + parts: typing.List[str] = lexer.get_tokens(cmdstr) if not parts: parts = [""] elif parts[-1].isspace(): @@ -305,7 +305,6 @@ class CommandManager(mitmproxy.types._CommandBase): Execute a command string. May raise CommandError. """ lex = lexer.create_lexer(cmdstr, self.oneword_commands) - self.command_parser.async_exec = False parsed_cmd = self.command_parser.parse(lexer=lex) return parsed_cmd diff --git a/mitmproxy/language/lexer.py b/mitmproxy/language/lexer.py index 96bca1ea1..c204b82f3 100644 --- a/mitmproxy/language/lexer.py +++ b/mitmproxy/language/lexer.py @@ -62,11 +62,8 @@ def create_lexer(cmdstr: str, oneword_commands: typing.Sequence[str]) -> lex.Lex return command_lexer.lexer -def get_tokens(cmdstr: str, state="interactive", - oneword_commands=None) -> typing.List[lex.LexToken]: - if oneword_commands is None: - oneword_commands = [] - lexer = create_lexer(cmdstr, oneword_commands) +def get_tokens(cmdstr: str, state="interactive") -> typing.List[lex.LexToken]: + lexer = create_lexer(cmdstr, []) # Switching to the other state lexer.begin(state) return list(lexer) diff --git a/mitmproxy/language/parser.py b/mitmproxy/language/parser.py index f85e01ba5..c3923ccfa 100644 --- a/mitmproxy/language/parser.py +++ b/mitmproxy/language/parser.py @@ -136,7 +136,7 @@ class CommandLanguageParser: errorlog=yacc.NullLogger(), **kwargs) def parse(self, lexer: lex.Lexer, - async_exec=False, **kwargs) -> typing.Any: + async_exec: bool=False, **kwargs) -> typing.Any: self.async_exec = async_exec self.parser.parse(lexer=lexer, **kwargs) self._reset_internals() diff --git a/mitmproxy/tools/console/consoleaddons.py b/mitmproxy/tools/console/consoleaddons.py index 54682bc88..be170f567 100644 --- a/mitmproxy/tools/console/consoleaddons.py +++ b/mitmproxy/tools/console/consoleaddons.py @@ -577,16 +577,12 @@ class ConsoleAddon: Edit the currently focused key binding. """ b = self._keyfocus() - print(f"""console.command [ console.key.bind - [{" ".join(b.contexts)}] - {b.key} - "{b.command}" ]""") - # self.console_command( - # "console.key.bind", - # ",".join(b.contexts), - # b.key, - # b.command, - # ) + self.console_command( + "console.key.bind", + ",".join(b.contexts), + b.key, + b.command, + ) def running(self): self.started = True diff --git a/mitmproxy/tools/console/keymap.py b/mitmproxy/tools/console/keymap.py index 2fac8601b..d85d7d68b 100644 --- a/mitmproxy/tools/console/keymap.py +++ b/mitmproxy/tools/console/keymap.py @@ -155,11 +155,6 @@ class Keymap: return self.executor(b.command) return key - def _get_braced_command(self, command): - tokens = lexer.get_tokens(command, self.oneword_commands) - - - keyAttrs = { "key": lambda x: isinstance(x, str),