summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkotfu <kotfu@kotfu.net>2018-04-29 12:43:11 -0600
committerkotfu <kotfu@kotfu.net>2018-04-29 12:43:11 -0600
commitfbc6d0b39fa1e84ea3de3b38b700c45189146429 (patch)
treef8f2d76c73282af2741cc38941aa0d2767e0b4a4
parent975818feb4f24c25e84b3586cfe68230f1ac84f5 (diff)
downloadcmd2-git-fbc6d0b39fa1e84ea3de3b38b700c45189146429.tar.gz
pipeTo -> pipe_to
-rwxr-xr-xcmd2/cmd2.py4
-rw-r--r--cmd2/parsing.py16
-rw-r--r--tests/test_parsing.py18
3 files changed, 19 insertions, 19 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 136d86b2..985e2b66 100755
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -2114,7 +2114,7 @@ class Cmd(cmd.Cmd):
:param statement: Statement - a parsed statement from the user
"""
- if statement.pipeTo:
+ if statement.pipe_to:
self.kept_state = Statekeeper(self, ('stdout',))
# Create a pipe with read and write sides
@@ -2129,7 +2129,7 @@ class Cmd(cmd.Cmd):
# We want Popen to raise an exception if it fails to open the process. Thus we don't set shell to True.
try:
- self.pipe_proc = subprocess.Popen(shlex.split(statement.pipeTo), stdin=subproc_stdin)
+ self.pipe_proc = subprocess.Popen(shlex.split(statement.pipe_to), stdin=subproc_stdin)
except Exception as ex:
# Restore stdout to what it was and close the pipe
self.stdout.close()
diff --git a/cmd2/parsing.py b/cmd2/parsing.py
index 63766a8c..9b548716 100644
--- a/cmd2/parsing.py
+++ b/cmd2/parsing.py
@@ -38,7 +38,7 @@ class Statement(str):
self.args = ''
self.terminator = None
self.suffix = None
- self.pipeTo = None
+ self.pipe_to = None
self.output = None
self.outputTo = None
@@ -56,9 +56,9 @@ class StatementParser():
self,
allow_redirection=True,
terminators=None,
- multiline_commands = None,
- aliases = None,
- shortcuts = [],
+ multiline_commands=None,
+ aliases=None,
+ shortcuts=[],
):
self.allow_redirection = allow_redirection
if terminators is None:
@@ -209,13 +209,13 @@ class StatementParser():
try:
# find the first pipe if it exists
pipe_pos = tokens.index('|')
- # set everything after the first pipe to result.pipeTo
- pipeTo = ' '.join(tokens[pipe_pos+1:])
+ # set everything after the first pipe to result.pipe_to
+ pipe_to = ' '.join(tokens[pipe_pos+1:])
# remove all the tokens after the pipe
tokens = tokens[:pipe_pos]
except ValueError:
# no pipe in the tokens
- pipeTo = None
+ pipe_to = None
if terminator:
# whatever is left is the suffix
@@ -242,7 +242,7 @@ class StatementParser():
result.inputFrom = inputFrom
result.output = output
result.outputTo = outputTo
- result.pipeTo = pipeTo
+ result.pipe_to = pipe_to
result.suffix = suffix
result.multiline_command = multiline_command
return result
diff --git a/tests/test_parsing.py b/tests/test_parsing.py
index 3fc7c171..01674136 100644
--- a/tests/test_parsing.py
+++ b/tests/test_parsing.py
@@ -65,7 +65,7 @@ def test_command_with_args(parser):
statement = parser.parse(line)
assert statement.command == 'command'
assert statement.args == 'with args'
- assert not statement.pipeTo
+ assert not statement.pipe_to
def test_parse_command_with_args_terminator_and_suffix(parser):
line = 'command with args and terminator; and suffix'
@@ -79,38 +79,38 @@ def test_hashcomment(parser):
statement = parser.parse('hi # this is all a comment')
assert statement.command == 'hi'
assert not statement.args
- assert not statement.pipeTo
+ assert not statement.pipe_to
def test_c_comment(parser):
statement = parser.parse('hi /* this is | all a comment */')
assert statement.command == 'hi'
assert not statement.args
- assert not statement.pipeTo
+ assert not statement.pipe_to
def test_c_comment_empty(parser):
statement = parser.parse('/* this is | all a comment */')
assert not statement.command
assert not statement.args
- assert not statement.pipeTo
+ assert not statement.pipe_to
def test_parse_what_if_quoted_strings_seem_to_start_comments(parser):
statement = parser.parse('what if "quoted strings /* seem to " start comments?')
assert statement.command == 'what'
assert statement.args == 'if "quoted strings /* seem to " start comments?'
- assert not statement.pipeTo
+ assert not statement.pipe_to
def test_simple_piped(parser):
statement = parser.parse('simple | piped')
assert statement.command == 'simple'
assert not statement.args
- assert statement.pipeTo == 'piped'
+ assert statement.pipe_to == 'piped'
def test_double_pipe_is_not_a_pipe(parser):
line = 'double-pipe || is not a pipe'
statement = parser.parse(line)
assert statement.command == 'double-pipe'
assert statement.args == '|| is not a pipe'
- assert not statement.pipeTo
+ assert not statement.pipe_to
def test_complex_pipe(parser):
line = 'command with args, terminator;sufx | piped'
@@ -119,7 +119,7 @@ def test_complex_pipe(parser):
assert statement.args == "with args, terminator"
assert statement.terminator == ';'
assert statement.suffix == 'sufx'
- assert statement.pipeTo == 'piped'
+ assert statement.pipe_to == 'piped'
def test_output_redirect(parser):
line = 'output into > afile.txt'
@@ -169,7 +169,7 @@ def test_pipe_and_redirect(parser):
assert statement.args == 'into'
assert statement.terminator == ';'
assert statement.suffix == 'sufx'
- assert statement.pipeTo == 'pipethrume plz'
+ assert statement.pipe_to == 'pipethrume plz'
assert statement.output == '>'
assert statement.outputTo == 'afile.txt'