Skip to content

Commit 5299661

Browse files
committed
Renamed some functions and updated comments.
1 parent 0f39f0b commit 5299661

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

cmd2/rich_utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,16 @@ def __init__(
160160
"Passing 'theme' is not allowed. Its behavior is controlled by the global APP_THEME and set_theme()."
161161
)
162162

163-
# Store the configuration used to create this console for caching purposes.
164-
self._config_key = self._generate_config_key(file=file, **kwargs)
163+
# Store the configuration key used by cmd2 to cache this console.
164+
self._config_key = self._build_config_key(file=file, **kwargs)
165165

166166
force_terminal: bool | None = None
167167
force_interactive: bool | None = None
168168

169169
if ALLOW_STYLE == AllowStyle.ALWAYS:
170170
force_terminal = True
171171

172-
# Turn off interactive mode if dest is not actually a terminal which supports it
172+
# Turn off interactive mode if dest is not a terminal which supports it.
173173
tmp_console = Console(file=file)
174174
force_interactive = tmp_console.is_interactive
175175
elif ALLOW_STYLE == AllowStyle.NEVER:
@@ -184,12 +184,12 @@ def __init__(
184184
)
185185

186186
@staticmethod
187-
def _generate_config_key(
187+
def _build_config_key(
188188
*,
189189
file: IO[str] | None,
190190
**kwargs: Any,
191191
) -> tuple[Any, ...]:
192-
"""Generate a key representing the settings used to initialize a console.
192+
"""Build a key representing the settings used to initialize a console.
193193
194194
This key includes the file identity, global settings (ALLOW_STYLE, APP_THEME),
195195
and any other settings passed in via kwargs.
@@ -216,7 +216,7 @@ def matches_config(
216216
:param kwargs: other console settings being checked
217217
:return: True if the settings match this console's configuration
218218
"""
219-
return self._config_key == self._generate_config_key(file=file, **kwargs)
219+
return self._config_key == self._build_config_key(file=file, **kwargs)
220220

221221
def on_broken_pipe(self) -> None:
222222
"""Override which raises BrokenPipeError instead of SystemExit."""

examples/async_printing.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def _get_alerts(self) -> list[str]:
103103

104104
return alerts
105105

106-
def _generate_alert_str(self) -> str:
106+
def _build_alert_str(self) -> str:
107107
"""Combines alerts into one string that can be printed to the terminal
108108
:return: the alert string.
109109
"""
@@ -125,8 +125,8 @@ def _generate_alert_str(self) -> str:
125125

126126
return alert_str
127127

128-
def _generate_colored_prompt(self) -> str:
129-
"""Randomly generates a colored prompt
128+
def _build_colored_prompt(self) -> str:
129+
"""Randomly builds a colored prompt
130130
:return: the new prompt.
131131
"""
132132
rand_num = random.randint(1, 6)
@@ -153,10 +153,10 @@ def _add_alerts_func(self) -> None:
153153

154154
while not self._stop_event.is_set():
155155
# Get any alerts that need to be printed
156-
alert_str = self._generate_alert_str()
156+
alert_str = self._build_alert_str()
157157

158-
# Generate a new prompt
159-
new_prompt = self._generate_colored_prompt()
158+
# Build a new prompt
159+
new_prompt = self._build_colored_prompt()
160160

161161
# Check if we have alerts to print
162162
if alert_str:

0 commit comments

Comments
 (0)