Skip to content

Commit b2dc994

Browse files
committed
Made some cmd2 module constants cmd2.Cmd class constants
1 parent ed25a1a commit b2dc994

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

cmd2/cmd2.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,6 @@
8989
except ImportError: # pragma: no cover
9090
ipython_available = False
9191

92-
INTERNAL_COMMAND_EPILOG = ("Notes:\n"
93-
" This command is for internal use and is not intended to be called from the\n"
94-
" command line.")
95-
96-
# Sorting keys for strings
97-
ALPHABETICAL_SORT_KEY = utils.norm_fold
98-
NATURAL_SORT_KEY = utils.natural_keys
99-
10092

10193
class _SavedReadlineSettings:
10294
"""readline settings that are backed up when switching between readline environments"""
@@ -140,6 +132,14 @@ class Cmd(cmd.Cmd):
140132
"""
141133
DEFAULT_EDITOR = utils.find_editor()
142134

135+
INTERNAL_COMMAND_EPILOG = ("Notes:\n"
136+
" This command is for internal use and is not intended to be called from the\n"
137+
" command line.")
138+
139+
# Sorting keys for strings
140+
ALPHABETICAL_SORT_KEY = utils.norm_fold
141+
NATURAL_SORT_KEY = utils.natural_keys
142+
143143
def __init__(self, completekey: str = 'tab', stdin=None, stdout=None, *,
144144
persistent_history_file: str = '', persistent_history_length: int = 1000,
145145
startup_script: str = '', use_ipython: bool = False,
@@ -194,7 +194,7 @@ def __init__(self, completekey: str = 'tab', stdin=None, stdout=None, *,
194194
self.continuation_prompt = '> '
195195
self.debug = False
196196
self.echo = False
197-
self.editor = self.DEFAULT_EDITOR
197+
self.editor = Cmd.DEFAULT_EDITOR
198198
self.feedback_to_output = False # Do not include nonessentials in >, | output by default (things like timing)
199199
self.locals_in_py = False
200200

@@ -330,7 +330,7 @@ def __init__(self, completekey: str = 'tab', stdin=None, stdout=None, *,
330330
# command and category names
331331
# alias, macro, settable, and shortcut names
332332
# tab completion results when self.matches_sorted is False
333-
self.default_sort_key = ALPHABETICAL_SORT_KEY
333+
self.default_sort_key = Cmd.ALPHABETICAL_SORT_KEY
334334

335335
############################################################################################################
336336
# The following variables are used by tab-completion functions. They are reset each time complete() is run

tests/test_completion.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,13 @@ def test_default_sort_key(cmd2_app):
187187
begidx = endidx - len(text)
188188

189189
# First do alphabetical sorting
190-
cmd2_app.default_sort_key = cmd2.cmd2.ALPHABETICAL_SORT_KEY
190+
cmd2_app.default_sort_key = cmd2.Cmd.ALPHABETICAL_SORT_KEY
191191
expected = ['1', '11', '2']
192192
first_match = complete_tester(text, line, begidx, endidx, cmd2_app)
193193
assert first_match is not None and cmd2_app.completion_matches == expected
194194

195195
# Now switch to natural sorting
196-
cmd2_app.default_sort_key = cmd2.cmd2.NATURAL_SORT_KEY
196+
cmd2_app.default_sort_key = cmd2.Cmd.NATURAL_SORT_KEY
197197
expected = ['1', '2', '11']
198198
first_match = complete_tester(text, line, begidx, endidx, cmd2_app)
199199
assert first_match is not None and cmd2_app.completion_matches == expected

0 commit comments

Comments
 (0)