mirror of
https://github.com/python/cpython.git
synced 2025-08-17 15:21:26 +00:00
pep8-fied distutils.dist module
This commit is contained in:
parent
cb76804b17
commit
ae6acfc9a1
1 changed files with 37 additions and 93 deletions
|
@ -267,22 +267,17 @@ Common commands: (see '--help-commands' for more)
|
|||
|
||||
self.finalize_options()
|
||||
|
||||
# __init__ ()
|
||||
|
||||
|
||||
def get_option_dict(self, command):
|
||||
"""Get the option dictionary for a given command. If that
|
||||
command's option dictionary hasn't been created yet, then create it
|
||||
and return the new dictionary; otherwise, return the existing
|
||||
option dictionary.
|
||||
"""
|
||||
|
||||
dict = self.command_options.get(command)
|
||||
if dict is None:
|
||||
dict = self.command_options[command] = {}
|
||||
return dict
|
||||
|
||||
|
||||
def dump_option_dicts(self, header=None, commands=None, indent=""):
|
||||
from pprint import pformat
|
||||
|
||||
|
@ -308,10 +303,6 @@ Common commands: (see '--help-commands' for more)
|
|||
for line in string.split(out, "\n"):
|
||||
print indent + " " + line
|
||||
|
||||
# dump_option_dicts ()
|
||||
|
||||
|
||||
|
||||
# -- Config file finding/parsing methods ---------------------------
|
||||
|
||||
def find_config_files(self):
|
||||
|
@ -355,9 +346,6 @@ Common commands: (see '--help-commands' for more)
|
|||
|
||||
return files
|
||||
|
||||
# find_config_files ()
|
||||
|
||||
|
||||
def parse_config_files(self, filenames=None):
|
||||
from ConfigParser import ConfigParser
|
||||
|
||||
|
@ -400,9 +388,6 @@ Common commands: (see '--help-commands' for more)
|
|||
except ValueError, msg:
|
||||
raise DistutilsOptionError, msg
|
||||
|
||||
# parse_config_files ()
|
||||
|
||||
|
||||
# -- Command-line parsing methods ----------------------------------
|
||||
|
||||
def parse_command_line(self):
|
||||
|
@ -478,8 +463,6 @@ Common commands: (see '--help-commands' for more)
|
|||
# All is well: return true
|
||||
return 1
|
||||
|
||||
# parse_command_line()
|
||||
|
||||
def _get_toplevel_options(self):
|
||||
"""Return the non-display options recognized at the top level.
|
||||
|
||||
|
@ -587,14 +570,11 @@ Common commands: (see '--help-commands' for more)
|
|||
|
||||
return args
|
||||
|
||||
# _parse_command_opts ()
|
||||
|
||||
def finalize_options(self):
|
||||
"""Set final values for all the options on the Distribution
|
||||
instance, analogous to the .finalize_options() method of Command
|
||||
objects.
|
||||
"""
|
||||
|
||||
keywords = self.metadata.keywords
|
||||
if keywords is not None:
|
||||
if type(keywords) is StringType:
|
||||
|
@ -607,10 +587,7 @@ Common commands: (see '--help-commands' for more)
|
|||
platformlist = string.split(platforms, ',')
|
||||
self.metadata.platforms = map(string.strip, platformlist)
|
||||
|
||||
def _show_help (self,
|
||||
parser,
|
||||
global_options=1,
|
||||
display_options=1,
|
||||
def _show_help(self, parser, global_options=1, display_options=1,
|
||||
commands=[]):
|
||||
"""Show help for the setup script command-line in the form of
|
||||
several lists of command-line options. 'parser' should be a
|
||||
|
@ -661,9 +638,6 @@ Common commands: (see '--help-commands' for more)
|
|||
print gen_usage(self.script_name)
|
||||
return
|
||||
|
||||
# _show_help ()
|
||||
|
||||
|
||||
def handle_display_options(self, option_order):
|
||||
"""If there were any non-global "display-only" options
|
||||
(--help-commands or the metadata display options) on the command
|
||||
|
@ -704,13 +678,10 @@ Common commands: (see '--help-commands' for more)
|
|||
|
||||
return any_display_options
|
||||
|
||||
# handle_display_options()
|
||||
|
||||
def print_command_list(self, commands, header, max_length):
|
||||
"""Print a subset of the list of all commands -- used by
|
||||
'print_commands()'.
|
||||
"""
|
||||
|
||||
print header + ":"
|
||||
|
||||
for cmd in commands:
|
||||
|
@ -724,9 +695,6 @@ Common commands: (see '--help-commands' for more)
|
|||
|
||||
print " %-*s %s" % (max_length, cmd, description)
|
||||
|
||||
# print_command_list ()
|
||||
|
||||
|
||||
def print_commands(self):
|
||||
"""Print out a help message listing all available commands with a
|
||||
description of each. The list is divided into "standard commands"
|
||||
|
@ -735,7 +703,6 @@ Common commands: (see '--help-commands' for more)
|
|||
descriptions come from the command class attribute
|
||||
'description'.
|
||||
"""
|
||||
|
||||
import distutils.command
|
||||
std_commands = distutils.command.__all__
|
||||
is_std = {}
|
||||
|
@ -761,8 +728,6 @@ Common commands: (see '--help-commands' for more)
|
|||
"Extra commands",
|
||||
max_length)
|
||||
|
||||
# print_commands ()
|
||||
|
||||
def get_command_list(self):
|
||||
"""Get a list of (command, description) tuples.
|
||||
The list is divided into "standard commands" (listed in
|
||||
|
@ -850,8 +815,6 @@ Common commands: (see '--help-commands' for more)
|
|||
raise DistutilsModuleError("invalid command '%s'" % command)
|
||||
|
||||
|
||||
# get_command_class ()
|
||||
|
||||
def get_command_obj(self, command, create=1):
|
||||
"""Return the command object for 'command'. Normally this object
|
||||
is cached on a previous call to 'get_command_obj()'; if no command
|
||||
|
@ -958,7 +921,6 @@ Common commands: (see '--help-commands' for more)
|
|||
|
||||
return command
|
||||
|
||||
|
||||
# -- Methods that operate on the Distribution ----------------------
|
||||
|
||||
def announce(self, msg, level=1):
|
||||
|
@ -972,7 +934,6 @@ Common commands: (see '--help-commands' for more)
|
|||
for cmd in self.commands:
|
||||
self.run_command(cmd)
|
||||
|
||||
|
||||
# -- Methods that operate on its Commands --------------------------
|
||||
|
||||
def run_command(self, command):
|
||||
|
@ -1029,9 +990,6 @@ Common commands: (see '--help-commands' for more)
|
|||
# to self.metadata.get_XXX. The actual code is in the
|
||||
# DistributionMetadata class, below.
|
||||
|
||||
# class Distribution
|
||||
|
||||
|
||||
class DistributionMetadata:
|
||||
"""Dummy class to hold the distribution meta-data: name, version,
|
||||
author, and so forth.
|
||||
|
@ -1071,13 +1029,9 @@ class DistributionMetadata:
|
|||
"""Write the PKG-INFO file into the release tree.
|
||||
"""
|
||||
pkg_info = open( os.path.join(base_dir, 'PKG-INFO'), 'w')
|
||||
|
||||
self.write_pkg_file(pkg_info)
|
||||
|
||||
pkg_info.close()
|
||||
|
||||
# write_pkg_info ()
|
||||
|
||||
def write_pkg_file(self, file):
|
||||
"""Write the PKG-INFO format data to a file object.
|
||||
"""
|
||||
|
@ -1112,7 +1066,6 @@ class DistributionMetadata:
|
|||
self._write_list(file, 'Obsoletes', self.get_obsoletes())
|
||||
|
||||
def _write_field(self, file, name, value):
|
||||
|
||||
if isinstance(value, unicode):
|
||||
value = value.encode(PKG_INFO_ENCODING)
|
||||
else:
|
||||
|
@ -1120,7 +1073,6 @@ class DistributionMetadata:
|
|||
file.write('%s: %s\n' % (name, value))
|
||||
|
||||
def _write_list (self, file, name, values):
|
||||
|
||||
for value in values:
|
||||
self._write_field(file, name, value)
|
||||
|
||||
|
@ -1148,14 +1100,10 @@ class DistributionMetadata:
|
|||
return self.maintainer_email or "UNKNOWN"
|
||||
|
||||
def get_contact(self):
|
||||
return (self.maintainer or
|
||||
self.author or
|
||||
"UNKNOWN")
|
||||
return self.maintainer or self.author or "UNKNOWN"
|
||||
|
||||
def get_contact_email(self):
|
||||
return (self.maintainer_email or
|
||||
self.author_email or
|
||||
"UNKNOWN")
|
||||
return self.maintainer_email or self.author_email or "UNKNOWN"
|
||||
|
||||
def get_url(self):
|
||||
return self.url or "UNKNOWN"
|
||||
|
@ -1183,7 +1131,6 @@ class DistributionMetadata:
|
|||
return self.download_url or "UNKNOWN"
|
||||
|
||||
# PEP 314
|
||||
|
||||
def get_requires(self):
|
||||
return self.requires or []
|
||||
|
||||
|
@ -1212,9 +1159,6 @@ class DistributionMetadata:
|
|||
distutils.versionpredicate.VersionPredicate(v)
|
||||
self.obsoletes = value
|
||||
|
||||
# class DistributionMetadata
|
||||
|
||||
|
||||
def fix_help_options(options):
|
||||
"""Convert a 4-tuple 'help_options' list as found in various command
|
||||
classes to the 3-tuple form required by FancyGetopt.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue