diff options
-rw-r--r-- | cmd2/cmd2.py | 10 | ||||
-rw-r--r-- | cmd2/transcript.py | 2 | ||||
-rwxr-xr-x | examples/alias_startup.py | 4 | ||||
-rw-r--r-- | examples/transcripts/exampleSession.txt | 2 | ||||
-rw-r--r-- | examples/transcripts/transcript_regex.txt | 2 |
5 files changed, 12 insertions, 8 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 136328b1..db96228b 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -1574,7 +1574,7 @@ class Cmd(cmd.Cmd): def get_all_commands(self) -> List[str]: """Returns a list of all commands.""" return [name[3:] for name in self.get_names() - if name.startswith('do_') and isinstance(getattr(self, name), Callable)] + if name.startswith('do_') and callable(getattr(self, name))] def get_visible_commands(self) -> List[str]: """Returns a list of commands that have not been hidden.""" @@ -1590,7 +1590,7 @@ class Cmd(cmd.Cmd): def get_help_topics(self) -> List[str]: """ Returns a list of help topics """ return [name[5:] for name in self.get_names() - if name.startswith('help_') and isinstance(getattr(self, name), Callable)] + if name.startswith('help_') and callable(getattr(self, name))] def complete_help(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: """ @@ -2895,13 +2895,13 @@ Paths or arguments that contain spaces must be enclosed in quotes if self.locals_in_py: def load_ipy(self, app): - banner = 'Entering an embedded IPython shell type quit() or <Ctrl>-d to exit ...' + banner = 'Entering an embedded IPython shell. Type quit() or <Ctrl>-d to exit ...' exit_msg = 'Leaving IPython, back to {}'.format(sys.argv[0]) embed(banner1=banner, exit_msg=exit_msg) load_ipy(self, bridge) else: def load_ipy(app): - banner = 'Entering an embedded IPython shell type quit() or <Ctrl>-d to exit ...' + banner = 'Entering an embedded IPython shell. Type quit() or <Ctrl>-d to exit ...' exit_msg = 'Leaving IPython, back to {}'.format(sys.argv[0]) embed(banner1=banner, exit_msg=exit_msg) load_ipy(bridge) @@ -3044,7 +3044,7 @@ a..b, a:b, a:, ..b items by indices (inclusive) # get the output out of the buffer output = membuf.read() # and add the regex-escaped output to the transcript - transcript += output.replace('/', '\/') + transcript += output.replace('/', r'\/') # Restore stdout to its original state self.stdout = saved_self_stdout diff --git a/cmd2/transcript.py b/cmd2/transcript.py index a6b4cb1a..3ac304ca 100644 --- a/cmd2/transcript.py +++ b/cmd2/transcript.py @@ -106,7 +106,7 @@ class Cmd2TestCase(unittest.TestCase): self.assertTrue(re.match(expected, result, re.MULTILINE | re.DOTALL), message) def _transform_transcript_expected(self, s: str) -> str: - """Parse the string with slashed regexes into a valid regex. + r"""Parse the string with slashed regexes into a valid regex. Given a string like: diff --git a/examples/alias_startup.py b/examples/alias_startup.py index 4ae91661..8a289e79 100755 --- a/examples/alias_startup.py +++ b/examples/alias_startup.py @@ -14,6 +14,10 @@ class AliasAndStartup(cmd2.Cmd): alias_script = os.path.join(os.path.dirname(__file__), '.cmd2rc') super().__init__(startup_script=alias_script) + def do_nothing(self, args): + """This command does nothing and produces no output.""" + pass + if __name__ == '__main__': app = AliasAndStartup() diff --git a/examples/transcripts/exampleSession.txt b/examples/transcripts/exampleSession.txt index 1d1b3b79..6318776f 100644 --- a/examples/transcripts/exampleSession.txt +++ b/examples/transcripts/exampleSession.txt @@ -9,7 +9,7 @@ debug: False echo: False editor: /.*?/ feedback_to_output: False -locals_in_py: True +locals_in_py: False maxrepeats: 3 prompt: (Cmd)/ / quiet: False diff --git a/examples/transcripts/transcript_regex.txt b/examples/transcripts/transcript_regex.txt index adf4d77e..08588ab1 100644 --- a/examples/transcripts/transcript_regex.txt +++ b/examples/transcripts/transcript_regex.txt @@ -9,7 +9,7 @@ debug: False echo: False editor: /.*?/ feedback_to_output: False -locals_in_py: True +locals_in_py: False maxrepeats: 3 prompt: (Cmd)/ / quiet: False |