mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-02-05 06:00:55 +03:00
Return env interpolation on Python 2 to support pypy 2
This commit is contained in:
parent
ecc2b585a0
commit
881764dc56
|
@ -52,17 +52,31 @@ if yaml:
|
|||
yaml.add_constructor('!path', yaml_env_marker_constructor)
|
||||
|
||||
|
||||
class EnvInterpolation(iniconfigparser.BasicInterpolation):
|
||||
"""Interpolation which expands environment variables in values."""
|
||||
if sys.version_info[0] == 3:
|
||||
class EnvInterpolation(iniconfigparser.BasicInterpolation):
|
||||
"""Interpolation which expands environment variables in values."""
|
||||
|
||||
def before_get(self, parser, section, option, value, defaults):
|
||||
value = super().before_get(parser, section, option, value, defaults)
|
||||
return os.path.expandvars(value)
|
||||
def before_get(self, parser, section, option, value, defaults):
|
||||
value = super().before_get(parser, section, option, value, defaults)
|
||||
return os.path.expandvars(value)
|
||||
|
||||
def _parse_ini_file(filepath):
|
||||
parser = iniconfigparser.ConfigParser(interpolation=EnvInterpolation())
|
||||
parser.read(filepath)
|
||||
return parser
|
||||
def _parse_ini_file(filepath):
|
||||
parser = iniconfigparser.ConfigParser(interpolation=EnvInterpolation())
|
||||
parser.read(filepath)
|
||||
return parser
|
||||
else:
|
||||
import StringIO
|
||||
|
||||
def _parse_ini_file(filepath):
|
||||
parser = iniconfigparser.ConfigParser()
|
||||
try:
|
||||
with open(filepath) as config_file:
|
||||
config_string = os.path.expandvars(config_file.read())
|
||||
except IOError:
|
||||
return parser
|
||||
else:
|
||||
parser.readfp(StringIO.StringIO(config_string))
|
||||
return parser
|
||||
|
||||
|
||||
cdef class Provider:
|
||||
|
|
Loading…
Reference in New Issue
Block a user