diff options
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/arg_print.py | 2 | ||||
-rwxr-xr-x | examples/cmd_as_argument.py | 2 | ||||
-rwxr-xr-x | examples/colors.py | 2 | ||||
-rwxr-xr-x | examples/decorator_example.py | 2 | ||||
-rwxr-xr-x | examples/example.py | 2 | ||||
-rwxr-xr-x | examples/hooks.py | 6 | ||||
-rwxr-xr-x | examples/pirate.py | 2 | ||||
-rwxr-xr-x | examples/plumbum_colors.py | 2 | ||||
-rwxr-xr-x | examples/python_scripting.py | 8 | ||||
-rw-r--r-- | examples/scripts/conditional.py | 4 |
10 files changed, 16 insertions, 16 deletions
diff --git a/examples/arg_print.py b/examples/arg_print.py index 48bcbd13..3f7f3815 100755 --- a/examples/arg_print.py +++ b/examples/arg_print.py @@ -19,7 +19,7 @@ class ArgumentAndOptionPrinter(cmd2.Cmd): def __init__(self): # Create command shortcuts which are typically 1 character abbreviations which can be used in place of a command - shortcuts = dict(self.DEFAULT_SHORTCUTS) + shortcuts = dict(cmd2.DEFAULT_SHORTCUTS) shortcuts.update({'$': 'aprint', '%': 'oprint'}) super().__init__(shortcuts=shortcuts) diff --git a/examples/cmd_as_argument.py b/examples/cmd_as_argument.py index 1e7901b9..49a50670 100755 --- a/examples/cmd_as_argument.py +++ b/examples/cmd_as_argument.py @@ -28,7 +28,7 @@ class CmdLineApp(cmd2.Cmd): MUMBLE_LAST = ['right?'] def __init__(self): - shortcuts = dict(self.DEFAULT_SHORTCUTS) + shortcuts = dict(cmd2.DEFAULT_SHORTCUTS) shortcuts.update({'&': 'speak'}) # Set use_ipython to True to enable the "ipy" command which embeds and interactive IPython shell super().__init__(allow_cli_args=False, use_ipython=True, multiline_commands=['orate'], shortcuts=shortcuts) diff --git a/examples/colors.py b/examples/colors.py index fdc0e0bd..f8a9dfdb 100755 --- a/examples/colors.py +++ b/examples/colors.py @@ -63,7 +63,7 @@ class CmdLineApp(cmd2.Cmd): MUMBLE_LAST = ['right?'] def __init__(self): - shortcuts = dict(self.DEFAULT_SHORTCUTS) + shortcuts = dict(cmd2.DEFAULT_SHORTCUTS) shortcuts.update({'&': 'speak'}) # Set use_ipython to True to enable the "ipy" command which embeds and interactive IPython shell super().__init__(use_ipython=True, multiline_commands=['orate'], shortcuts=shortcuts) diff --git a/examples/decorator_example.py b/examples/decorator_example.py index bb0d58c0..4f68653e 100755 --- a/examples/decorator_example.py +++ b/examples/decorator_example.py @@ -19,7 +19,7 @@ import cmd2 class CmdLineApp(cmd2.Cmd): """ Example cmd2 application. """ def __init__(self, ip_addr=None, port=None, transcript_files=None): - shortcuts = dict(self.DEFAULT_SHORTCUTS) + shortcuts = dict(cmd2.DEFAULT_SHORTCUTS) shortcuts.update({'&': 'speak'}) # Set use_ipython to True to enable the "ipy" command which embeds and interactive IPython shell super().__init__(use_ipython=False, transcript_files=transcript_files, multiline_commands=['orate'], diff --git a/examples/example.py b/examples/example.py index a1ec893c..24be5d5d 100755 --- a/examples/example.py +++ b/examples/example.py @@ -26,7 +26,7 @@ class CmdLineApp(cmd2.Cmd): MUMBLE_LAST = ['right?'] def __init__(self): - shortcuts = dict(self.DEFAULT_SHORTCUTS) + shortcuts = dict(cmd2.DEFAULT_SHORTCUTS) shortcuts.update({'&': 'speak'}) # Set use_ipython to True to enable the "ipy" command which embeds and interactive IPython shell super().__init__(use_ipython=False, multiline_commands=['orate'], shortcuts=shortcuts) diff --git a/examples/hooks.py b/examples/hooks.py index 42224403..39a7a0d5 100755 --- a/examples/hooks.py +++ b/examples/hooks.py @@ -66,7 +66,7 @@ class CmdLineApp(cmd2.Cmd): command_pattern = re.compile(r'^([^\s\d]+)(\d+)') match = command_pattern.search(command) if match: - data.statement = self.statement_parser.parse("{} {} {}".format( + data.statement = self._statement_parser.parse("{} {} {}".format( match.group(1), match.group(2), '' if data.statement.args is None else data.statement.args @@ -76,7 +76,7 @@ class CmdLineApp(cmd2.Cmd): def downcase_hook(self, data: cmd2.plugin.PostparsingData) -> cmd2.plugin.PostparsingData: """A hook to make uppercase commands lowercase.""" command = data.statement.command.lower() - data.statement = self.statement_parser.parse("{} {}".format( + data.statement = self._statement_parser.parse("{} {}".format( command, '' if data.statement.args is None else data.statement.args )) @@ -90,7 +90,7 @@ class CmdLineApp(cmd2.Cmd): possible_cmds = [cmd for cmd in self.get_all_commands() if cmd.startswith(data.statement.command)] if len(possible_cmds) == 1: raw = data.statement.raw.replace(data.statement.command, possible_cmds[0], 1) - data.statement = self.statement_parser.parse(raw) + data.statement = self._statement_parser.parse(raw) return data @cmd2.with_argument_list diff --git a/examples/pirate.py b/examples/pirate.py index 9abbe4e6..699ee80c 100755 --- a/examples/pirate.py +++ b/examples/pirate.py @@ -29,7 +29,7 @@ class Pirate(cmd2.Cmd): """A piratical example cmd2 application involving looting and drinking.""" def __init__(self): """Initialize the base class as well as this one""" - shortcuts = dict(self.DEFAULT_SHORTCUTS) + shortcuts = dict(cmd2.DEFAULT_SHORTCUTS) shortcuts.update({'~': 'sing'}) super().__init__(multiline_commands=['sing'], terminators=[MULTILINE_TERMINATOR, '...'], shortcuts=shortcuts) diff --git a/examples/plumbum_colors.py b/examples/plumbum_colors.py index 774dc7e4..2c57c22b 100755 --- a/examples/plumbum_colors.py +++ b/examples/plumbum_colors.py @@ -66,7 +66,7 @@ class CmdLineApp(cmd2.Cmd): MUMBLE_LAST = ['right?'] def __init__(self): - shortcuts = dict(self.DEFAULT_SHORTCUTS) + shortcuts = dict(cmd2.DEFAULT_SHORTCUTS) shortcuts.update({'&': 'speak'}) # Set use_ipython to True to enable the "ipy" command which embeds and interactive IPython shell super().__init__(use_ipython=True, multiline_commands=['orate'], shortcuts=shortcuts) diff --git a/examples/python_scripting.py b/examples/python_scripting.py index 3e8f64ef..c45648bc 100755 --- a/examples/python_scripting.py +++ b/examples/python_scripting.py @@ -58,7 +58,7 @@ class CmdLineApp(cmd2.Cmd): if not arglist or len(arglist) != 1: self.perror("cd requires exactly 1 argument:", traceback_war=False) self.do_help('cd') - self._last_result = cmd2.CommandResult('', 'Bad arguments') + self.last_result = cmd2.CommandResult('', 'Bad arguments') return # Convert relative paths to absolute paths @@ -84,7 +84,7 @@ class CmdLineApp(cmd2.Cmd): if err: self.perror(err, traceback_war=False) - self._last_result = cmd2.CommandResult(out, err, data) + self.last_result = cmd2.CommandResult(out, err, data) # Enable tab completion for cd command def complete_cd(self, text, line, begidx, endidx): @@ -100,7 +100,7 @@ class CmdLineApp(cmd2.Cmd): if unknown: self.perror("dir does not take any positional arguments:", traceback_war=False) self.do_help('dir') - self._last_result = cmd2.CommandResult('', 'Bad arguments') + self.last_result = cmd2.CommandResult('', 'Bad arguments') return # Get the contents as a list @@ -113,7 +113,7 @@ class CmdLineApp(cmd2.Cmd): self.stdout.write(fmt.format(f)) self.stdout.write('\n') - self._last_result = cmd2.CommandResult(data=contents) + self.last_result = cmd2.CommandResult(data=contents) if __name__ == '__main__': diff --git a/examples/scripts/conditional.py b/examples/scripts/conditional.py index 724bb3ee..2e307cb4 100644 --- a/examples/scripts/conditional.py +++ b/examples/scripts/conditional.py @@ -27,10 +27,10 @@ original_dir = os.getcwd() app('cd {}'.format(directory)) # Conditionally do something based on the results of the last command -if self._last_result: +if self.last_result: print('\nContents of directory {!r}:'.format(directory)) app('dir -l') - print('{}\n'.format(self._last_result.data)) + print('{}\n'.format(self.last_result.data)) # Change back to where we were print('Changing back to original directory: {!r}'.format(original_dir)) |