mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-07-04 12:23:14 +03:00
Make code layout enhancements
This commit is contained in:
parent
b64d5172eb
commit
77769d8dd6
File diff suppressed because it is too large
Load Diff
|
@ -746,24 +746,22 @@ def copy(object base_container):
|
||||||
:return: Declarative container's copying decorator.
|
:return: Declarative container's copying decorator.
|
||||||
:rtype: callable(:py:class:`DeclarativeContainer`)
|
:rtype: callable(:py:class:`DeclarativeContainer`)
|
||||||
"""
|
"""
|
||||||
def _get_providers_memo(from_providers, source_providers):
|
def _get_memo_for_matching_names(from_providers, source_providers):
|
||||||
memo = dict()
|
memo = {}
|
||||||
|
|
||||||
for name, provider in from_providers.items():
|
for name, provider in from_providers.items():
|
||||||
try:
|
if name not in source_providers:
|
||||||
source_provider = source_providers[name]
|
|
||||||
except KeyError:
|
|
||||||
continue
|
continue
|
||||||
else:
|
source_provider = source_providers[name]
|
||||||
memo[id(source_provider)] = provider
|
|
||||||
|
|
||||||
|
memo[id(source_provider)] = provider
|
||||||
if hasattr(provider, 'providers') and hasattr(source_provider, 'providers'):
|
if hasattr(provider, 'providers') and hasattr(source_provider, 'providers'):
|
||||||
sub_memo = _get_providers_memo(provider.providers, source_provider.providers)
|
sub_memo = _get_memo_for_matching_names(provider.providers, source_provider.providers)
|
||||||
memo.update(sub_memo)
|
memo.update(sub_memo)
|
||||||
return memo
|
return memo
|
||||||
|
|
||||||
def _decorator(new_container):
|
def _decorator(new_container):
|
||||||
memo = _get_providers_memo(new_container.cls_providers, base_container.providers)
|
memo = {}
|
||||||
|
memo.update(_get_memo_for_matching_names(new_container.cls_providers, base_container.providers))
|
||||||
|
|
||||||
providers_copy = providers.deepcopy(base_container.providers, memo)
|
providers_copy = providers.deepcopy(base_container.providers, memo)
|
||||||
for name, provider in six.iteritems(providers_copy):
|
for name, provider in six.iteritems(providers_copy):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user