Remove Python 2 specific pieces from providers module

This commit is contained in:
Roman Mogylatov 2020-09-24 21:32:58 -04:00
parent c2a5fbd077
commit ecc2b585a0
4 changed files with 4707 additions and 5676 deletions

View File

@ -883,7 +883,7 @@ struct __pyx_opt_args_19dependency_injector_9providers_deepcopy {
/* "providers.pxd":7
*
* # Base providers
* cdef class Provider(object): # <<<<<<<<<<<<<<
* cdef class Provider: # <<<<<<<<<<<<<<
* cdef tuple __overridden
* cdef Provider __last_overriding
*/
@ -1537,7 +1537,7 @@ struct __pyx_obj_19dependency_injector_10containers___pyx_scope_struct_5_copy {
/* "providers.pxd":7
*
* # Base providers
* cdef class Provider(object): # <<<<<<<<<<<<<<
* cdef class Provider: # <<<<<<<<<<<<<<
* cdef tuple __overridden
* cdef Provider __last_overriding
*/

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@ cimport cython
# Base providers
cdef class Provider(object):
cdef class Provider:
cdef tuple __overridden
cdef Provider __last_overriding

View File

@ -40,15 +40,7 @@ from .errors import (
cimport cython
if sys.version_info[0] == 3: # pragma: no cover
CLASS_TYPES = (type,)
else: # pragma: no cover
CLASS_TYPES = (type, types.ClassType)
copy._deepcopy_dispatch[types.MethodType] = \
lambda obj, memo: type(obj)(obj.im_func,
copy.deepcopy(obj.im_self, memo),
obj.im_class)
CLASS_TYPES = (type,)
if yaml:
yaml_env_marker_pattern = re.compile(r'\$\{([^}^{]+)\}')
@ -59,34 +51,21 @@ if yaml:
yaml.add_implicit_resolver('!path', yaml_env_marker_pattern)
yaml.add_constructor('!path', yaml_env_marker_constructor)
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)
class EnvInterpolation(iniconfigparser.BasicInterpolation):
"""Interpolation which expands environment variables in values."""
def _parse_ini_file(filepath):
parser = iniconfigparser.ConfigParser(interpolation=EnvInterpolation())
parser.read(filepath)
return parser
else:
import StringIO
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()
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
def _parse_ini_file(filepath):
parser = iniconfigparser.ConfigParser(interpolation=EnvInterpolation())
parser.read(filepath)
return parser
cdef class Provider(object):
cdef class Provider:
"""Base provider class.
:py:class:`Provider` is callable (implements ``__call__`` method). Every