diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-06-15 15:00:59 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-06-15 15:00:59 -0400 |
commit | 70bf9e1a12b89bb913c11fb07893ab4b9cab2576 (patch) | |
tree | 27bb62898d635bcaa8e6e8182d52f5105210b3f6 /examples | |
parent | c12ba0ff11b3a8fd083c641cb9149aff6494bbf9 (diff) | |
download | cmd2-git-70bf9e1a12b89bb913c11fb07893ab4b9cab2576.tar.gz |
Began work to minimize public API
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/async_printing.py | 10 | ||||
-rwxr-xr-x | examples/hooks.py | 6 | ||||
-rwxr-xr-x | examples/tab_autocompletion.py | 6 |
3 files changed, 11 insertions, 11 deletions
diff --git a/examples/async_printing.py b/examples/async_printing.py index 3089070f..b59d3d6d 100755 --- a/examples/async_printing.py +++ b/examples/async_printing.py @@ -48,7 +48,7 @@ class AlerterApp(cmd2.Cmd): def _preloop_hook(self) -> None: """ Start the alerter thread """ - # This runs after cmdloop() acquires self.terminal_lock, which will be locked until the prompt appears. + # This runs after cmdloop() acquires self._terminal_lock, which will be locked until the prompt appears. # Therefore this is the best place to start the alerter thread since there is no risk of it alerting # before the prompt is displayed. You can also start it via a command if its not something that should # be running during the entire application. See do_start_alerts(). @@ -60,7 +60,7 @@ class AlerterApp(cmd2.Cmd): def _postloop_hook(self) -> None: """ Stops the alerter thread """ - # After this function returns, cmdloop() releases self.terminal_lock which could make the alerter + # After this function returns, cmdloop() releases self._terminal_lock which could make the alerter # thread think the prompt is on screen. Therefore this is the best place to stop the alerter thread. # You can also stop it via a command. See do_stop_alerts(). self._stop_thread = True @@ -169,9 +169,9 @@ class AlerterApp(cmd2.Cmd): self._next_alert_time = 0 while not self._stop_thread: - # Always acquire terminal_lock before printing alerts or updating the prompt + # Always acquire _terminal_lock before printing alerts or updating the prompt # To keep the app responsive, do not block on this call - if self.terminal_lock.acquire(blocking=False): + if self._terminal_lock.acquire(blocking=False): # Get any alerts that need to be printed alert_str = self._generate_alert_str() @@ -191,7 +191,7 @@ class AlerterApp(cmd2.Cmd): self.async_update_prompt(new_prompt) # Don't forget to release the lock - self.terminal_lock.release() + self._terminal_lock.release() time.sleep(0.5) 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/tab_autocompletion.py b/examples/tab_autocompletion.py index 8f27cb90..4919eca8 100755 --- a/examples/tab_autocompletion.py +++ b/examples/tab_autocompletion.py @@ -382,7 +382,7 @@ class TabCompleteExample(cmd2.Cmd): self, arg_choices=choices) - tokens, _ = self.tokens_for_completion(line, begidx, endidx) + tokens, _ = self._tokens_for_completion(line, begidx, endidx) results = completer.complete_command(tokens, text, line, begidx, endidx) return results @@ -443,7 +443,7 @@ class TabCompleteExample(cmd2.Cmd): # Demonstrates a custom completion function that does more with the command line than is # allowed by the standard completion functions def _filter_episodes(self, text, line, begidx, endidx, show_db, user_lib): - tokens, _ = self.tokens_for_completion(line, begidx, endidx) + tokens, _ = self._tokens_for_completion(line, begidx, endidx) show_id = tokens[3] if show_id: if show_id in show_db: @@ -530,7 +530,7 @@ class TabCompleteExample(cmd2.Cmd): self, subcmd_args_lookup=library_subcommand_groups) - tokens, _ = self.tokens_for_completion(line, begidx, endidx) + tokens, _ = self._tokens_for_completion(line, begidx, endidx) results = completer.complete_command(tokens, text, line, begidx, endidx) return results |