diff options
-rwxr-xr-x | cmd2/cmd2.py | 8 | ||||
-rw-r--r-- | cmd2/parsing.py | 10 | ||||
-rw-r--r-- | tests/test_parsing.py | 10 |
3 files changed, 14 insertions, 14 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 985e2b66..0c738991 100755 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -2142,16 +2142,16 @@ class Cmd(cmd.Cmd): # Re-raise the exception raise ex elif statement.output: - if (not statement.outputTo) and (not can_clip): + if (not statement.output_to) and (not can_clip): raise EnvironmentError('Cannot redirect to paste buffer; install ``xclip`` and re-run to enable') self.kept_state = Statekeeper(self, ('stdout',)) self.kept_sys = Statekeeper(sys, ('stdout',)) self.redirecting = True - if statement.outputTo: + if statement.output_to: mode = 'w' if statement.output == 2 * self.redirector: mode = 'a' - sys.stdout = self.stdout = open(os.path.expanduser(statement.outputTo), mode) + sys.stdout = self.stdout = open(os.path.expanduser(statement.output_to), mode) else: sys.stdout = self.stdout = tempfile.TemporaryFile(mode="w+") if statement.output == '>>': @@ -2165,7 +2165,7 @@ class Cmd(cmd.Cmd): # If we have redirected output to a file or the clipboard or piped it to a shell command, then restore state if self.kept_state is not None: # If we redirected output to the clipboard - if statement.output and not statement.outputTo: + if statement.output and not statement.output_to: self.stdout.seek(0) write_to_paste_buffer(self.stdout.read()) diff --git a/cmd2/parsing.py b/cmd2/parsing.py index 9b548716..0ba0736d 100644 --- a/cmd2/parsing.py +++ b/cmd2/parsing.py @@ -40,7 +40,7 @@ class Statement(str): self.suffix = None self.pipe_to = None self.output = None - self.outputTo = None + self.output_to = None @property def command_and_args(self): @@ -186,11 +186,11 @@ class StatementParser(): # check for output redirect output = None - outputTo = None + output_to = None try: output_pos = tokens.index('>') output = '>' - outputTo = ' '.join(tokens[output_pos+1:]) + output_to = ' '.join(tokens[output_pos+1:]) # remove all the tokens after the output redirect tokens = tokens[:output_pos] except ValueError: @@ -199,7 +199,7 @@ class StatementParser(): try: output_pos = tokens.index('>>') output = '>>' - outputTo = ' '.join(tokens[output_pos+1:]) + output_to = ' '.join(tokens[output_pos+1:]) # remove all tokens after the output redirect tokens = tokens[:output_pos] except ValueError: @@ -241,7 +241,7 @@ class StatementParser(): result.terminator = terminator result.inputFrom = inputFrom result.output = output - result.outputTo = outputTo + result.output_to = output_to result.pipe_to = pipe_to result.suffix = suffix result.multiline_command = multiline_command diff --git a/tests/test_parsing.py b/tests/test_parsing.py index 01674136..cfc5aa76 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -127,7 +127,7 @@ def test_output_redirect(parser): assert statement.command == 'output' assert statement.args == 'into' assert statement.output == '>' - assert statement.outputTo == 'afile.txt' + assert statement.output_to == 'afile.txt' def test_output_redirect_with_dash_in_path(parser): line = 'output into > python-cmd2/afile.txt' @@ -135,7 +135,7 @@ def test_output_redirect_with_dash_in_path(parser): assert statement.command == 'output' assert statement.args == 'into' assert statement.output == '>' - assert statement.outputTo == 'python-cmd2/afile.txt' + assert statement.output_to == 'python-cmd2/afile.txt' def test_output_redirect_append(parser): line = 'output appended to >> /tmp/afile.txt' @@ -143,7 +143,7 @@ def test_output_redirect_append(parser): assert statement.command == 'output' assert statement.args == 'appended to' assert statement.output == '>>' - assert statement.outputTo == '/tmp/afile.txt' + assert statement.output_to == '/tmp/afile.txt' def test_parse_input_redirect(parser): line = '< afile.txt' @@ -171,7 +171,7 @@ def test_pipe_and_redirect(parser): assert statement.suffix == 'sufx' assert statement.pipe_to == 'pipethrume plz' assert statement.output == '>' - assert statement.outputTo == 'afile.txt' + assert statement.output_to == 'afile.txt' def test_parse_output_to_paste_buffer(parser): line = 'output to paste buffer >> ' @@ -252,7 +252,7 @@ def test_parse_redirect_to_unicode_filename(parser): assert statement.command == 'dir' assert statement.args == 'home' assert statement.output == '>' - assert statement.outputTo == 'café' + assert statement.output_to == 'café' def test_parse_input_redirect_from_unicode_filename(parser): line = '< café' |