mirror of
https://github.com/python/cpython.git
synced 2025-10-17 04:08:28 +00:00
gh-118761: Improve import time of cmd
module (#130056)
* Improve import time of `cmd` module * Remove string import
This commit is contained in:
parent
6f07016bf0
commit
99d965635a
2 changed files with 10 additions and 3 deletions
11
Lib/cmd.py
11
Lib/cmd.py
|
@ -42,12 +42,15 @@ listings of documented functions, miscellaneous topics, and undocumented
|
|||
functions respectively.
|
||||
"""
|
||||
|
||||
import inspect, string, sys
|
||||
import sys
|
||||
|
||||
__all__ = ["Cmd"]
|
||||
|
||||
PROMPT = '(Cmd) '
|
||||
IDENTCHARS = string.ascii_letters + string.digits + '_'
|
||||
IDENTCHARS = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
'abcdefghijklmnopqrstuvwxyz'
|
||||
'0123456789'
|
||||
'_')
|
||||
|
||||
class Cmd:
|
||||
"""A simple framework for writing line-oriented command interpreters.
|
||||
|
@ -303,9 +306,11 @@ class Cmd:
|
|||
try:
|
||||
func = getattr(self, 'help_' + arg)
|
||||
except AttributeError:
|
||||
from inspect import cleandoc
|
||||
|
||||
try:
|
||||
doc=getattr(self, 'do_' + arg).__doc__
|
||||
doc = inspect.cleandoc(doc)
|
||||
doc = cleandoc(doc)
|
||||
if doc:
|
||||
self.stdout.write("%s\n"%str(doc))
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue