Correctly handle options with pip in their name

This commit is contained in:
Donald Stufft 2014-12-23 19:36:18 -05:00
parent 4a6b32e558
commit 7a139f273a
1 changed files with 7 additions and 3 deletions

View File

@ -4,6 +4,7 @@ from __future__ import absolute_import
import sys
import optparse
import os
import re
import textwrap
from distutils.util import strtobool
@ -16,6 +17,9 @@ from pip.locations import (
from pip.utils import appdirs, get_terminal_size
_environ_prefix_re = re.compile(r"^PIP_", re.I)
class PrettyHelpFormatter(optparse.IndentedHelpFormatter):
"""A prettier/less verbose help formatter for optparse."""
@ -239,11 +243,11 @@ class ConfigOptionParser(CustomOptionParser):
return self.config.items(name)
return []
def get_environ_vars(self, prefix='PIP_'):
def get_environ_vars(self):
"""Returns a generator with all environmental vars with prefix PIP_"""
for key, val in os.environ.items():
if key.startswith(prefix):
yield (key.replace(prefix, '').lower(), val)
if _environ_prefix_re.search(key):
yield (_environ_prefix_re.sub("", key).lower(), val)
def get_default_values(self):
"""Overridding to make updating the defaults after instantiation of