Adding possibility to get all providers by type from catalog

This commit is contained in:
Roman Mogilatov 2015-01-28 14:50:48 +02:00
parent ae2d1036d7
commit 7f88e4ffdd

View File

@ -33,14 +33,14 @@ class AbstractCatalog(object):
return attribute
@classmethod
def __all_providers__(cls):
def __all_providers__(cls, provider_type=Provider):
"""
Returns set of all class providers.
"""
providers = set()
for attr_name in set(dir(cls)) - set(dir(AbstractCatalog)):
provider = getattr(cls, attr_name)
if not isinstance(provider, Provider):
if not isinstance(provider, provider_type):
continue
providers.add((attr_name, provider))
return providers