mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-23 01:56:58 +03:00
Make minor import refactorings
This commit is contained in:
parent
234e5cb3fc
commit
bab7265a90
|
@ -1,7 +1,6 @@
|
|||
"""Catalog module."""
|
||||
|
||||
from six import iteritems
|
||||
from six import add_metaclass
|
||||
import six
|
||||
|
||||
from .errors import Error
|
||||
from .utils import is_provider
|
||||
|
@ -15,7 +14,7 @@ class CatalogMetaClass(type):
|
|||
"""Meta class factory."""
|
||||
providers = dict()
|
||||
new_attributes = dict()
|
||||
for name, value in iteritems(attributes):
|
||||
for name, value in six.iteritems(attributes):
|
||||
if is_provider(value):
|
||||
providers[name] = value
|
||||
new_attributes[name] = value
|
||||
|
@ -26,7 +25,7 @@ class CatalogMetaClass(type):
|
|||
return cls
|
||||
|
||||
|
||||
@add_metaclass(CatalogMetaClass)
|
||||
@six.add_metaclass(CatalogMetaClass)
|
||||
class AbstractCatalog(object):
|
||||
|
||||
"""Abstract providers catalog."""
|
||||
|
@ -54,7 +53,7 @@ class AbstractCatalog(object):
|
|||
def filter(cls, provider_type):
|
||||
"""Return dict of providers, that are instance of provided type."""
|
||||
return dict([(name, provider)
|
||||
for name, provider in iteritems(cls.providers)
|
||||
for name, provider in six.iteritems(cls.providers)
|
||||
if isinstance(provider, provider_type)])
|
||||
|
||||
@classmethod
|
||||
|
@ -63,7 +62,7 @@ class AbstractCatalog(object):
|
|||
|
||||
:type overriding: AbstractCatalog
|
||||
"""
|
||||
for name, provider in iteritems(overriding.providers):
|
||||
for name, provider in six.iteritems(overriding.providers):
|
||||
cls.providers[name].override(provider)
|
||||
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
"""Utils module."""
|
||||
|
||||
from six import class_types
|
||||
import six
|
||||
|
||||
from .errors import Error
|
||||
|
||||
|
||||
def is_provider(instance):
|
||||
"""Check if instance is provider instance."""
|
||||
return (not isinstance(instance, class_types) and
|
||||
return (not isinstance(instance, six.class_types) and
|
||||
getattr(instance, '__IS_PROVIDER__', False) is True)
|
||||
|
||||
|
||||
|
@ -21,7 +21,7 @@ def ensure_is_provider(instance):
|
|||
|
||||
def is_injection(instance):
|
||||
"""Check if instance is injection instance."""
|
||||
return (not isinstance(instance, class_types) and
|
||||
return (not isinstance(instance, six.class_types) and
|
||||
getattr(instance, '__IS_INJECTION__', False) is True)
|
||||
|
||||
|
||||
|
@ -35,19 +35,19 @@ def ensure_is_injection(instance):
|
|||
|
||||
def is_kwarg_injection(instance):
|
||||
"""Check if instance is keyword argument injection instance."""
|
||||
return (not isinstance(instance, class_types) and
|
||||
return (not isinstance(instance, six.class_types) and
|
||||
getattr(instance, '__IS_KWARG_INJECTION__', False) is True)
|
||||
|
||||
|
||||
def is_attribute_injection(instance):
|
||||
"""Check if instance is attribute injection instance."""
|
||||
return (not isinstance(instance, class_types) and
|
||||
return (not isinstance(instance, six.class_types) and
|
||||
getattr(instance, '__IS_ATTRIBUTE_INJECTION__', False) is True)
|
||||
|
||||
|
||||
def is_method_injection(instance):
|
||||
"""Check if instance is method injection instance."""
|
||||
return (not isinstance(instance, class_types) and
|
||||
return (not isinstance(instance, six.class_types) and
|
||||
getattr(instance, '__IS_METHOD_INJECTION__', False) is True)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user