mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 09:36:48 +03:00
Adding possibility to get all providers by type from catalog
This commit is contained in:
parent
ae2d1036d7
commit
7f88e4ffdd
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user