diff options
author | Todd Leonhardt <tleonhardt@gmail.com> | 2017-03-14 16:53:22 -0400 |
---|---|---|
committer | Todd Leonhardt <tleonhardt@gmail.com> | 2017-03-14 16:53:22 -0400 |
commit | 28eba1722b12f1a270fffd9a8596044c5be6e7cd (patch) | |
tree | e85991423f473cbff3f31ca0814602c20ff49b51 /examples/python_scripting.py | |
parent | 7786709db04be8385226d6a56046a74983e8c983 (diff) | |
download | cmd2-git-28eba1722b12f1a270fffd9a8596044c5be6e7cd.tar.gz |
Improved the CmdResult namedtuple subclass
The last two arguments (err and war) are now optional.
Only the 1st argument (out) is required.
err and war default to empty strings.
Diffstat (limited to 'examples/python_scripting.py')
-rwxr-xr-x | examples/python_scripting.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/examples/python_scripting.py b/examples/python_scripting.py index ea556952..cecd7ec7 100755 --- a/examples/python_scripting.py +++ b/examples/python_scripting.py @@ -57,7 +57,7 @@ class CmdLineApp(Cmd): if not arg or len(arg) != 1: self.perror("cd requires exactly 1 argument:", traceback_war=False) self.do_help('cd') - self._last_result = CmdResult('', 'Bad arguments', '') + self._last_result = CmdResult('', 'Bad arguments') return # Convert relative paths to absolute paths @@ -66,7 +66,6 @@ class CmdLineApp(Cmd): # Make sure the directory exists, is a directory, and we have read access out = '' err = '' - war = '' if not os.path.isdir(path): err = '{!r} is not a directory'.format(path) elif not os.access(path, os.R_OK): @@ -82,8 +81,9 @@ class CmdLineApp(Cmd): if err: self.perror(err, traceback_war=False) - self._last_result = CmdResult(out, err, war) + self._last_result = CmdResult(out, err) + # noinspection PyUnusedLocal def complete_cd(self, text, line, begidx, endidx): """Handles completion of arguments for the cd command. @@ -103,7 +103,7 @@ class CmdLineApp(Cmd): if arg: self.perror("dir does not take any arguments:", traceback_war=False) self.do_help('dir') - self._last_result = CmdResult('', 'Bad arguments', '') + self._last_result = CmdResult('', 'Bad arguments') return # Get the contents as a list @@ -116,7 +116,7 @@ class CmdLineApp(Cmd): self.stdout.write(fmt.format(f)) self.stdout.write('\n') - self._last_result = CmdResult(contents, '', '') + self._last_result = CmdResult(contents) if __name__ == '__main__': |