[Python-checkins] distutils2: merged from upstream
tarek.ziade
python-checkins at python.org
Sun Sep 19 10:20:22 CEST 2010
tarek.ziade pushed 7f04bc9fb0c4 to distutils2:
http://hg.python.org/distutils2/rev/7f04bc9fb0c4
changeset: 644:7f04bc9fb0c4
parent: 643:876665b5723a
parent: 593:5695ab44cbec
user: Konrad Delong <konryd at gmail.com>
date: Mon Aug 16 11:43:38 2010 +0200
summary: merged from upstream
files: src/distutils2/dist.py
diff --git a/src/CONTRIBUTORS.txt b/src/CONTRIBUTORS.txt
--- a/src/CONTRIBUTORS.txt
+++ b/src/CONTRIBUTORS.txt
@@ -12,6 +12,7 @@
- Ali Afshar
- Ãric Araujo
- Pior Bastida
+- Anthony Baxter
- Titus Brown
- Nicolas Cadou
- Konrad Delong
diff --git a/src/distutils2/dist.py b/src/distutils2/dist.py
--- a/src/distutils2/dist.py
+++ b/src/distutils2/dist.py
@@ -15,7 +15,7 @@
from distutils2.errors import (DistutilsOptionError, DistutilsArgError,
DistutilsModuleError, DistutilsClassError)
-from distutils2.fancy_getopt import FancyGetopt, translate_longopt
+from distutils2.fancy_getopt import FancyGetopt
from distutils2.util import check_environ, strtobool, resolve_name
from distutils2 import log
from distutils2.metadata import DistributionMetadata
@@ -115,8 +115,7 @@
('convert-2to3-doctests', None,
"use 2to3 to convert doctests in seperate text files"),
]
- display_option_names = map(lambda x: translate_longopt(x[0]),
- display_options)
+ display_option_names = [x[0].replace('-', '_') for x in display_options]
# negative options are options that exclude other options
negative_opt = {'quiet': 'verbose'}
@@ -452,6 +451,7 @@
# for display options we return immediately
if self.handle_display_options(option_order):
return
+
while args:
args = self._parse_command_opts(parser, args)
if args is None: # user asked for help (and got it)
@@ -557,7 +557,7 @@
isinstance(cmd_class.help_options, list)):
help_option_found = 0
for (help_option, short, desc, func) in cmd_class.help_options:
- if hasattr(opts, parser.get_attr_name(help_option)):
+ if hasattr(opts, help_option.replace('-', '_')):
help_option_found = 1
if hasattr(func, '__call__'):
func()
@@ -666,7 +666,7 @@
for opt, val in option_order:
if val and is_display_option.get(opt):
- opt = translate_longopt(opt)
+ opt = opt.replace('-', '_')
value = self.metadata[opt]
if opt in ['keywords', 'platform']:
print(','.join(value))
@@ -864,7 +864,8 @@
log.debug(" %s = %s (from %s)" % (option, value,
source))
try:
- bool_opts = map(translate_longopt, command_obj.boolean_options)
+ bool_opts = [x.replace('-', '_')
+ for x in command_obj.boolean_options]
except AttributeError:
bool_opts = []
try:
diff --git a/src/distutils2/fancy_getopt.py b/src/distutils2/fancy_getopt.py
--- a/src/distutils2/fancy_getopt.py
+++ b/src/distutils2/fancy_getopt.py
@@ -106,12 +106,6 @@
option with long name 'long_option'."""
return long_option in self.option_index
- def get_attr_name (self, long_option):
- """Translate long option name 'long_option' to the form it
- has as an attribute of some object: ie., translate hyphens
- to underscores."""
- return long_option.replace('-', '_')
-
def _check_alias_dict (self, aliases, what):
assert isinstance(aliases, dict)
for (alias, opt) in aliases.items():
@@ -217,7 +211,7 @@
("invalid long option name '%s' " +
"(must be letters, numbers, hyphens only") % long
- self.attr_name[long] = self.get_attr_name(long)
+ self.attr_name[long] = long.replace('-', '_')
if short:
self.short_opts.append(short)
self.short2long[short[0]] = long
@@ -462,13 +456,6 @@
return lines
-def translate_longopt(opt):
- """Convert a long option name to a valid Python identifier by
- changing "-" to "_".
- """
- return opt.replace('-', '_')
-
-
class OptionDummy(object):
"""Dummy class just used as a place to hold command-line option
values as instance attributes."""
diff --git a/src/distutils2/tests/test_util.py b/src/distutils2/tests/test_util.py
--- a/src/distutils2/tests/test_util.py
+++ b/src/distutils2/tests/test_util.py
@@ -74,6 +74,7 @@
class UtilTestCase(support.EnvironGuard,
support.TempdirManager,
+ support.LoggingCatcher,
unittest.TestCase):
def setUp(self):
--
Repository URL: http://hg.python.org/distutils2
More information about the Python-checkins
mailing list