summaryrefslogtreecommitdiff
path: root/src/distutils2
diff options
context:
space:
mode:
authorKonrad Delong <konryd@gmail.com>2010-08-16 11:43:38 +0200
committerKonrad Delong <konryd@gmail.com>2010-08-16 11:43:38 +0200
commitb6d2cb35cea6fedff65f5ddeb6d67411eee08f49 (patch)
treeceb990fb8eed1a8f2195c36e416ccf3b36ed5861 /src/distutils2
parentc096167c660b76ccb91bc308c0d4d280d2010490 (diff)
parentde5322eea12fddf555b8b975513f03c0ccc5b525 (diff)
downloaddisutils2-b6d2cb35cea6fedff65f5ddeb6d67411eee08f49.tar.gz
merged from upstream
Diffstat (limited to 'src/distutils2')
-rw-r--r--src/distutils2/dist.py13
-rw-r--r--src/distutils2/fancy_getopt.py15
-rw-r--r--src/distutils2/tests/test_util.py1
3 files changed, 9 insertions, 20 deletions
diff --git a/src/distutils2/dist.py b/src/distutils2/dist.py
index 65ce631..2f491ca 100644
--- a/src/distutils2/dist.py
+++ b/src/distutils2/dist.py
@@ -15,7 +15,7 @@ from ConfigParser import RawConfigParser
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 @@ Common commands: (see '--help-commands' for more)
('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 @@ Common commands: (see '--help-commands' for more)
# 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 @@ Common commands: (see '--help-commands' for more)
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 @@ Common commands: (see '--help-commands' for more)
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 @@ Common commands: (see '--help-commands' for more)
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
index fef85fc..304fb8a 100644
--- a/src/distutils2/fancy_getopt.py
+++ b/src/distutils2/fancy_getopt.py
@@ -106,12 +106,6 @@ class FancyGetopt(object):
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 @@ class FancyGetopt(object):
("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 @@ def wrap_text (text, width):
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
index 85352d4..0907433 100644
--- a/src/distutils2/tests/test_util.py
+++ b/src/distutils2/tests/test_util.py
@@ -74,6 +74,7 @@ class FakePopen(object):
class UtilTestCase(support.EnvironGuard,
support.TempdirManager,
+ support.LoggingCatcher,
unittest.TestCase):
def setUp(self):