mirror of
https://github.com/python/cpython.git
synced 2025-10-02 05:12:23 +00:00
bpo-30166: Import command-line parsing modules only when needed. (#1293)
This commit is contained in:
parent
1c4670ea0c
commit
7e4db2f253
7 changed files with 20 additions and 12 deletions
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
import argparse
|
|
||||||
from codeop import CommandCompiler, compile_command
|
from codeop import CommandCompiler, compile_command
|
||||||
|
|
||||||
__all__ = ["InteractiveInterpreter", "InteractiveConsole", "interact",
|
__all__ = ["InteractiveInterpreter", "InteractiveConsole", "interact",
|
||||||
|
@ -303,6 +302,8 @@ def interact(banner=None, readfunc=None, local=None, exitmsg=None):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
import argparse
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('-q', action='store_true',
|
parser.add_argument('-q', action='store_true',
|
||||||
help="don't print version and copyright messages")
|
help="don't print version and copyright messages")
|
||||||
|
|
|
@ -93,7 +93,6 @@ __all__ = [
|
||||||
]
|
]
|
||||||
|
|
||||||
import __future__
|
import __future__
|
||||||
import argparse
|
|
||||||
import difflib
|
import difflib
|
||||||
import inspect
|
import inspect
|
||||||
import linecache
|
import linecache
|
||||||
|
@ -2741,6 +2740,8 @@ __test__ = {"_TestClass": _TestClass,
|
||||||
|
|
||||||
|
|
||||||
def _test():
|
def _test():
|
||||||
|
import argparse
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="doctest runner")
|
parser = argparse.ArgumentParser(description="doctest runner")
|
||||||
parser.add_argument('-v', '--verbose', action='store_true', default=False,
|
parser.add_argument('-v', '--verbose', action='store_true', default=False,
|
||||||
help='print very verbose output for all tests')
|
help='print very verbose output for all tests')
|
||||||
|
|
|
@ -87,7 +87,6 @@ __all__ = [
|
||||||
"SimpleHTTPRequestHandler", "CGIHTTPRequestHandler",
|
"SimpleHTTPRequestHandler", "CGIHTTPRequestHandler",
|
||||||
]
|
]
|
||||||
|
|
||||||
import argparse
|
|
||||||
import copy
|
import copy
|
||||||
import datetime
|
import datetime
|
||||||
import email.utils
|
import email.utils
|
||||||
|
@ -1227,6 +1226,8 @@ def test(HandlerClass=BaseHTTPRequestHandler,
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
import argparse
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--cgi', action='store_true',
|
parser.add_argument('--cgi', action='store_true',
|
||||||
help='Run as CGI Server')
|
help='Run as CGI Server')
|
||||||
|
|
|
@ -18,11 +18,10 @@ if TkVersion < 8.5:
|
||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
|
|
||||||
from code import InteractiveInterpreter
|
from code import InteractiveInterpreter
|
||||||
import getopt
|
|
||||||
import linecache
|
import linecache
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
from platform import python_version, system
|
from platform import python_version
|
||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -31,14 +30,12 @@ import time
|
||||||
import tokenize
|
import tokenize
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from idlelib import testing # bool value
|
|
||||||
from idlelib.colorizer import ColorDelegator
|
from idlelib.colorizer import ColorDelegator
|
||||||
from idlelib.config import idleConf
|
from idlelib.config import idleConf
|
||||||
from idlelib import debugger
|
from idlelib import debugger
|
||||||
from idlelib import debugger_r
|
from idlelib import debugger_r
|
||||||
from idlelib.editor import EditorWindow, fixwordbreaks
|
from idlelib.editor import EditorWindow, fixwordbreaks
|
||||||
from idlelib.filelist import FileList
|
from idlelib.filelist import FileList
|
||||||
from idlelib import macosx
|
|
||||||
from idlelib.outwin import OutputWindow
|
from idlelib.outwin import OutputWindow
|
||||||
from idlelib import rpc
|
from idlelib import rpc
|
||||||
from idlelib.run import idle_formatwarning, PseudoInputFile, PseudoOutputFile
|
from idlelib.run import idle_formatwarning, PseudoInputFile, PseudoOutputFile
|
||||||
|
@ -1371,6 +1368,11 @@ echo "import sys; print(sys.argv)" | idle - "foobar"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
import getopt
|
||||||
|
from platform import system
|
||||||
|
from idlelib import testing # bool value
|
||||||
|
from idlelib import macosx
|
||||||
|
|
||||||
global flist, root, use_subprocess
|
global flist, root, use_subprocess
|
||||||
|
|
||||||
capture_warnings(True)
|
capture_warnings(True)
|
||||||
|
|
|
@ -25,10 +25,8 @@
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
|
||||||
import time
|
import time
|
||||||
import marshal
|
import marshal
|
||||||
from optparse import OptionParser
|
|
||||||
|
|
||||||
__all__ = ["run", "runctx", "Profile"]
|
__all__ = ["run", "runctx", "Profile"]
|
||||||
|
|
||||||
|
@ -179,7 +177,7 @@ class Profile:
|
||||||
self.t = self.get_time()
|
self.t = self.get_time()
|
||||||
self.simulate_call('profiler')
|
self.simulate_call('profiler')
|
||||||
|
|
||||||
# Heavily optimized dispatch routine for os.times() timer
|
# Heavily optimized dispatch routine for time.process_time() timer
|
||||||
|
|
||||||
def trace_dispatch(self, frame, event, arg):
|
def trace_dispatch(self, frame, event, arg):
|
||||||
timer = self.timer
|
timer = self.timer
|
||||||
|
@ -552,6 +550,9 @@ class Profile:
|
||||||
#****************************************************************************
|
#****************************************************************************
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
import os
|
||||||
|
from optparse import OptionParser
|
||||||
|
|
||||||
usage = "profile.py [-o output_file_path] [-s sort] scriptfile [arg] ..."
|
usage = "profile.py [-o output_file_path] [-s sort] scriptfile [arg] ..."
|
||||||
parser = OptionParser(usage=usage)
|
parser = OptionParser(usage=usage)
|
||||||
parser.allow_interspersed_args = False
|
parser.allow_interspersed_args = False
|
||||||
|
|
|
@ -22,7 +22,6 @@ __version__ = "6"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import getopt
|
|
||||||
import tokenize
|
import tokenize
|
||||||
if not hasattr(tokenize, 'NL'):
|
if not hasattr(tokenize, 'NL'):
|
||||||
raise ValueError("tokenize.NL doesn't exist -- tokenize module too old")
|
raise ValueError("tokenize.NL doesn't exist -- tokenize module too old")
|
||||||
|
@ -40,6 +39,8 @@ def errprint(*args):
|
||||||
sys.stderr.write("\n")
|
sys.stderr.write("\n")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
import getopt
|
||||||
|
|
||||||
global verbose, filename_only
|
global verbose, filename_only
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(sys.argv[1:], "qv")
|
opts, args = getopt.getopt(sys.argv[1:], "qv")
|
||||||
|
|
|
@ -48,7 +48,7 @@ Sample use, programmatically
|
||||||
r.write_results(show_missing=True, coverdir="/tmp")
|
r.write_results(show_missing=True, coverdir="/tmp")
|
||||||
"""
|
"""
|
||||||
__all__ = ['Trace', 'CoverageResults']
|
__all__ = ['Trace', 'CoverageResults']
|
||||||
import argparse
|
|
||||||
import linecache
|
import linecache
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
@ -609,6 +609,7 @@ class Trace:
|
||||||
callers=self._callers)
|
callers=self._callers)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
import argparse
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--version', action='version', version='trace 2.0')
|
parser.add_argument('--version', action='version', version='trace 2.0')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue