updating Catalog override method name

This commit is contained in:
Roman Mogilatov 2015-03-12 12:45:15 +02:00
parent ff4a092dab
commit 0c1c13be33
2 changed files with 8 additions and 5 deletions

View File

@ -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
View File

@ -0,0 +1,3 @@
"""
"""