diff options
Diffstat (limited to 'pip/baseparser.py')
-rw-r--r-- | pip/baseparser.py | 62 |
1 files changed, 28 insertions, 34 deletions
diff --git a/pip/baseparser.py b/pip/baseparser.py index 5e4898530..b3864f3da 100644 --- a/pip/baseparser.py +++ b/pip/baseparser.py @@ -46,14 +46,11 @@ class ConfigOptionParser(optparse.OptionParser): config = {} # 1. config files for section in ('global', self.name): - config.update(dict(self.get_config_section(section))) + config.update(self.normalize_keys(self.get_config_section(section))) # 2. environmental variables - config.update(dict(self.get_environ_vars())) + config.update(self.normalize_keys(self.get_environ_vars())) # Then set the options with those values for key, val in config.items(): - key = key.replace('_', '-') - if not key.startswith('--'): - key = '--%s' % key # only prefer long opts option = self.get_option(key) if option is not None: # ignore empty values @@ -75,6 +72,18 @@ class ConfigOptionParser(optparse.OptionParser): defaults[option.dest] = val return defaults + def normalize_keys(self, items): + """Return a config dictionary with normalized keys regardless of + whether the keys were specified in environment variables or in config + files""" + normalized = {} + for key, val in items: + key = key.replace('_', '-') + if not key.startswith('--'): + key = '--%s' % key # only prefer long opts + normalized[key] = val + return normalized + def get_config_section(self, name): """Get a section of a configuration""" if self.config.has_section(name): @@ -123,41 +132,12 @@ parser.add_option( action='store_true', help='Show help') parser.add_option( - '-E', '--environment', - dest='venv', - metavar='DIR', - help='virtualenv environment to run pip in (either give the ' - 'interpreter or the environment base directory)') -parser.add_option( - '-s', '--enable-site-packages', - dest='site_packages', - action='store_true', - help='Include site-packages in virtualenv if one is to be ' - 'created. Ignored if --environment is not used or ' - 'the virtualenv already exists.') -parser.add_option( - # Defines a default root directory for virtualenvs, relative - # virtualenvs names/paths are considered relative to it. - '--virtualenv-base', - dest='venv_base', - type='str', - default='', - help=optparse.SUPPRESS_HELP) -parser.add_option( # Run only if inside a virtualenv, bail if not. '--require-virtualenv', '--require-venv', dest='require_venv', action='store_true', default=False, help=optparse.SUPPRESS_HELP) -parser.add_option( - # Use automatically an activated virtualenv instead of installing - # globally. -E will be ignored if used. - '--respect-virtualenv', '--respect-venv', - dest='respect_venv', - action='store_true', - default=False, - help=optparse.SUPPRESS_HELP) parser.add_option( '-v', '--verbose', @@ -229,4 +209,18 @@ parser.add_option( default='', help=optparse.SUPPRESS_HELP) +parser.add_option( + # Option when path already exist + '--exists-action', + dest='exists_action', + type='choice', + choices=['s', 'i', 'w', 'b'], + default=[], + action='append', + help="Default action when a path already exists." + "Use this option more then one time to specify " + "another action if a certain option is not " + "available, choices: " + "(s)witch, (i)gnore, (w)ipe, (b)ackup") + parser.disable_interspersed_args() |