summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorCatherine Devlin <catherine.devlin@gsa.gov>2017-05-29 21:01:37 -0500
committerCatherine Devlin <catherine.devlin@gsa.gov>2017-05-29 21:01:37 -0500
commite01ff81d323068d6fd62ccdacc36b2474ee4e2d6 (patch)
tree7bca3f0cfb4a64a138036a71e07751dc9afcf77a /cmd2.py
parent762c94717482090dd4d63de5950e8dd1500419c9 (diff)
downloadcmd2-git-e01ff81d323068d6fd62ccdacc36b2474ee4e2d6.tar.gz
Remove unused `parseline` method
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py32
1 files changed, 3 insertions, 29 deletions
diff --git a/cmd2.py b/cmd2.py
index a8171c2f..d15e023c 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -548,7 +548,8 @@ def replace_with_file_contents(fname):
"""
if fname:
try:
- result = open(os.path.expanduser(fname[0])).read()
+ with open(os.path.expanduser(fname[0])) as source_file:
+ result = source_file.read()
except IOError:
result = '< %s' % fname[0] # wasn't a file after all
else:
@@ -880,33 +881,6 @@ class Cmd(cmd.Cmd):
"""
return stop
- def parseline(self, line):
- """Parse the line into a command name and a string containing the arguments.
-
- Used for command tab completion. Returns a tuple containing (command, args, line).
- 'command' and 'args' may be None if the line couldn't be parsed.
-
- :param line: str - line read by readline
- :return: (str, str, str) - tuple containing (command, args, line)
- """
- line = line.strip()
-
- if not line:
- # Deal with empty line or all whitespace line
- return None, None, line
-
- # Expand command shortcuts to the full command name
- for (shortcut, expansion) in self.shortcuts:
- if line.startswith(shortcut):
- line = line.replace(shortcut, expansion + ' ', 1)
- break
-
- i, n = 0, len(line)
- while i < n and line[i] in self.identchars:
- i += 1
- command, arg = line[:i], line[i:].strip()
- return command, arg, line
-
def onecmd_plus_hooks(self, line):
"""Top-level function called by cmdloop() to handle parsing a line and running the command and all of its hooks.
@@ -1882,7 +1856,7 @@ relative to the already-running script's directory.
self.perror('Problem accessing script from %s: \n%s' % (targetname, e))
return
keepstate = Statekeeper(self, ('stdin', 'use_rawinput', 'prompt',
- 'continuation_prompt', 'current_script_dir'))
+ 'continuation_prompt', '_current_script_dir'))
self.stdin = target
self.use_rawinput = False
self.prompt = self.continuation_prompt = ''