@@ -0,0 +1,3089 @@
+%22%22%22IoC containers module.%22%22%22%0A%0Aimport six%0A%0Afrom dependency_injector import utils%0A%0A%0Aclass DeclarativeContainerMetaClass(type):%0A    %22%22%22Declarative inversion of control container meta class.%22%22%22%0A%0A    def __new__(mcs, class_name, bases, attributes):%0A        %22%22%22Declarative container class factory.%22%22%22%0A        cls_providers = tuple((name, provider)%0A                              for name, provider in six.iteritems(attributes)%0A                              if utils.is_provider(provider))%0A%0A        inherited_providers = tuple((name, provider)%0A                                    for base in bases if utils.is_catalog(base)%0A                                    for name, provider in six.iteritems(%0A                                        base.cls_providers))%0A%0A        attributes%5B'cls_providers'%5D = dict(cls_providers)%0A        attributes%5B'inherited_providers'%5D = dict(inherited_providers)%0A%0A        return type.__new__(mcs, class_name, bases, attributes)%0A%0A    def __setattr__(cls, name, value):%0A        %22%22%22Set class attribute.%0A%0A        If value of attribute is provider, it will be added into providers%0A        dictionary.%0A        %22%22%22%0A        if utils.is_provider(value):%0A            cls.providers%5Bname%5D = value%0A        super(DeclarativeContainerMetaClass, cls).__setattr__(name, value)%0A%0A%0Aclass Container(object):%0A    %22%22%22Inversion of control container.%22%22%22%0A%0A    __IS_CATALOG__ = True%0A%0A    def __init__(self):%0A        %22%22%22Initializer.%22%22%22%0A        self.providers = dict()%0A%0A    def bind_providers(self, **providers):%0A        %22%22%22Bind providers to the container.%22%22%22%0A        for name, provider in six.iteritems(providers):%0A            setattr(self, name, utils.ensure_is_provider(provider))%0A        return self%0A%0A    def __setattr__(self, name, value):%0A        %22%22%22Set instance attribute.%0A%0A        If value of attribute is provider, it will be added into providers%0A        dictionary.%0A        %22%22%22%0A        if utils.is_provider(value):%0A            self.providers%5Bname%5D = value%0A        super(Container, self).__setattr__(name, value)%0A%0A%0A@six.add_metaclass(DeclarativeContainerMetaClass)%0Aclass DeclarativeContainer(object):%0A    %22%22%22Declarative inversion of control container.%22%22%22%0A%0A    cls_providers = dict()%0A    inherited_providers = dict()%0A%0A    def __init__(self):%0A        %22%22%22Initializer.%22%22%22%0A        self.providers = dict()%0A        self.providers.update(self.__class__.inherited_providers)%0A        self.providers.update(self.__class__.cls_providers)%0A        super(DeclarativeContainer, self).__init__()%0A%0A%0Adef override(declarative_container):%0A    %22%22%22:py:class:%60DeclarativeContainer%60 overriding decorator.%0A%0A    :param declarative_container: Container that should be overridden by%0A                                  decorated container.%0A    :type declarative_container: :py:class:%60DeclarativeContainer%60%0A%0A    :return: Declarative container's overriding decorator.%0A    :rtype: callable(:py:class:%60DeclarativeContainer%60)%0A    %22%22%22%0A    def decorator(overriding_container):%0A        %22%22%22Overriding decorator.%22%22%22%0A        declarative_container.override(overriding_container)%0A        return overriding_container%0A    return decorator%0A

Add containers module