summaryrefslogtreecommitdiff
path: root/cmd2/parsing.py
diff options
context:
space:
mode:
authorkotfu <kotfu@kotfu.net>2018-04-29 09:38:15 -0600
committerkotfu <kotfu@kotfu.net>2018-04-29 09:38:15 -0600
commit5c14b3845f6a872e3e5b236f8caab6b4f3472f8f (patch)
tree36bd1629f24b5941dfbb98a233a3a0b596221908 /cmd2/parsing.py
parent85a3cc1320bafc2a44c75b630835bcc0635b61de (diff)
downloadcmd2-git-5c14b3845f6a872e3e5b236f8caab6b4f3472f8f.tar.gz
Cleanup requested changes in pull request
Diffstat (limited to 'cmd2/parsing.py')
-rw-r--r--cmd2/parsing.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/cmd2/parsing.py b/cmd2/parsing.py
index b6c58db7..22b558b3 100644
--- a/cmd2/parsing.py
+++ b/cmd2/parsing.py
@@ -6,8 +6,6 @@ import re
import shlex
from typing import List, Tuple
-import cmd2
-
BLANK_LINE = '\n'
def _comment_replacer(match):
@@ -20,7 +18,7 @@ def _comment_replacer(match):
class Statement(str):
"""String subclass with additional attributes to store the results of parsing.
-
+
The cmd module in the standard library passes commands around as a
string. To retain backwards compatibility, cmd2 does the same. However, we
need a place to capture the additional output of the command parsing, so we add
@@ -29,8 +27,9 @@ class Statement(str):
The string portion of the class contains the arguments, but not the command, nor
the output redirection clauses.
"""
- def __init__(self, object):
- self.raw = str(object)
+ def __init__(self, obj):
+ super().__init__()
+ self.raw = str(obj)
self.command = None
self.multilineCommand = None
# has to be an empty string for compatibility with standard library cmd
@@ -40,7 +39,7 @@ class Statement(str):
self.pipeTo = None
self.output = None
self.outputTo = None
-
+
@property
def command_and_args(self):
"""Combine command and args with a space separating them"""
@@ -48,7 +47,7 @@ class Statement(str):
class StatementParser():
"""Parse raw text into command components.
-
+
Shortcuts is a list of tuples with each tuple containing the shortcut and the expansion.
"""
def __init__(
@@ -207,7 +206,7 @@ class StatementParser():
except ValueError:
# no pipe in the tokens
pipeTo = None
-
+
if terminator:
# whatever is left is the suffix
suffix = ' '.join(tokens)