mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-25 11:04:01 +03:00
updating Catalog override method name
This commit is contained in:
parent
ff4a092dab
commit
0c1c13be33
|
@ -25,7 +25,7 @@ class AbstractCatalog(object):
|
||||||
return attribute
|
return attribute
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __all_providers__(cls, provider_type=Provider):
|
def all_providers(cls, provider_type=Provider):
|
||||||
"""Return set of all class providers."""
|
"""Return set of all class providers."""
|
||||||
providers = set()
|
providers = set()
|
||||||
for attr_name in set(dir(cls)) - set(dir(AbstractCatalog)):
|
for attr_name in set(dir(cls)) - set(dir(AbstractCatalog)):
|
||||||
|
@ -36,22 +36,22 @@ class AbstractCatalog(object):
|
||||||
return providers
|
return providers
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __override___(cls, overriding):
|
def override(cls, overriding):
|
||||||
"""
|
"""
|
||||||
Override current catalog providers by overriding catalog providers.
|
Override current catalog providers by overriding catalog providers.
|
||||||
|
|
||||||
:param overriding: AbstractCatalog
|
:param overriding: AbstractCatalog
|
||||||
"""
|
"""
|
||||||
overridden = overriding.__all_providers__() - cls.__all_providers__()
|
overridden = overriding.all_providers() - cls.all_providers()
|
||||||
for name, provider in overridden:
|
for name, provider in overridden:
|
||||||
overridden_provider = getattr(cls, name)
|
overridden_provider = getattr(cls, name)
|
||||||
overridden_provider.__override__(provider)
|
overridden_provider.override(provider)
|
||||||
|
|
||||||
|
|
||||||
def overrides(catalog):
|
def overrides(catalog):
|
||||||
"""Catalog overriding decorator."""
|
"""Catalog overriding decorator."""
|
||||||
def decorator(overriding_catalog):
|
def decorator(overriding_catalog):
|
||||||
"""Overriding decorator."""
|
"""Overriding decorator."""
|
||||||
catalog.__override___(overriding_catalog)
|
catalog.override(overriding_catalog)
|
||||||
return overriding_catalog
|
return overriding_catalog
|
||||||
return decorator
|
return decorator
|
||||||
|
|
3
tests/test_providers.py
Normal file
3
tests/test_providers.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
"""
|
||||||
|
|
||||||
|
"""
|
Loading…
Reference in New Issue
Block a user