mirror of https://github.com/pypa/pip
Correctly handle options with pip in their name
This commit is contained in:
parent
4a6b32e558
commit
7a139f273a
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue