mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Changed so all the help-generating functions are defined, at module-level,
in the module of the command classes that have command-specific help options. This lets us keep the principle of lazily importing the ccompiler module, and also gets away from defining non-methods at class level.
This commit is contained in:
parent
55fced3df9
commit
3459381e2a
5 changed files with 56 additions and 41 deletions
|
|
@ -14,6 +14,18 @@ from distutils.errors import *
|
|||
from distutils.util import get_platform
|
||||
|
||||
|
||||
def show_formats ():
|
||||
"""Print list of available formats (arguments to "--format" option).
|
||||
"""
|
||||
from distutils.fancy_getopt import FancyGetopt
|
||||
formats=[]
|
||||
for format in bdist.format_commands:
|
||||
formats.append(("formats=" + format, None,
|
||||
bdist.format_command[format][1]))
|
||||
pretty_printer = FancyGetopt(formats)
|
||||
pretty_printer.print_help("List of available distribution formats:")
|
||||
|
||||
|
||||
class bdist (Command):
|
||||
|
||||
description = "create a built (binary) distribution"
|
||||
|
|
@ -24,6 +36,11 @@ class bdist (Command):
|
|||
"formats for distribution (comma-separated list)"),
|
||||
]
|
||||
|
||||
help_options = [
|
||||
('help-formats', None,
|
||||
"lists available distribution formats", show_formats),
|
||||
]
|
||||
|
||||
# The following commands do not take a format option from bdist
|
||||
no_format_option = ('bdist_rpm',)
|
||||
|
||||
|
|
@ -38,24 +55,9 @@ class bdist (Command):
|
|||
'ztar': ('bdist_dumb', "compressed tar file"),
|
||||
'tar': ('bdist_dumb', "tar file"),
|
||||
'zip': ('bdist_dumb', "ZIP file"),
|
||||
}
|
||||
|
||||
def show_formats ():
|
||||
"""Print list of available formats (arguments to "--format" option).
|
||||
"""
|
||||
from distutils.fancy_getopt import FancyGetopt
|
||||
formats=[]
|
||||
for format in bdist.format_command.keys():
|
||||
formats.append(("formats="+format, None,
|
||||
bdist.format_command[format][1]))
|
||||
formats.sort()
|
||||
pretty_printer = FancyGetopt(formats)
|
||||
pretty_printer.print_help("List of available distribution formats:")
|
||||
|
||||
help_options = [
|
||||
('help-formats', None,
|
||||
"lists available distribution formats",show_formats),
|
||||
]
|
||||
}
|
||||
# establish the preferred order
|
||||
format_commands = ['rpm', 'gztar', 'bztar', 'ztar', 'tar', 'zip']
|
||||
|
||||
|
||||
def initialize_options (self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue