mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-02-12 01:20:51 +03:00
Minor providers.Config refactoring
This commit is contained in:
parent
08c7e7048f
commit
65f47b1222
|
@ -301,7 +301,7 @@ class Config(Provider):
|
||||||
|
|
||||||
def __getattr__(self, item):
|
def __getattr__(self, item):
|
||||||
"""Return instance of deferred config."""
|
"""Return instance of deferred config."""
|
||||||
return _DeferredConfig(paths=(item,),
|
return _DeferredConfig(parents=(item,),
|
||||||
root_config=self)
|
root_config=self)
|
||||||
|
|
||||||
def __call__(self, paths=None):
|
def __call__(self, paths=None):
|
||||||
|
@ -320,19 +320,19 @@ class _DeferredConfig(Provider):
|
||||||
Deferred config providers provide an value from the root config object.
|
Deferred config providers provide an value from the root config object.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__slots__ = ('paths', 'root_config')
|
__slots__ = ('parents', 'root_config')
|
||||||
|
|
||||||
def __init__(self, paths, root_config):
|
def __init__(self, parents, root_config):
|
||||||
"""Initializer."""
|
"""Initializer."""
|
||||||
self.paths = paths
|
self.parents = parents
|
||||||
self.root_config = root_config
|
self.root_config = root_config
|
||||||
super(_DeferredConfig, self).__init__()
|
super(_DeferredConfig, self).__init__()
|
||||||
|
|
||||||
def __getattr__(self, item):
|
def __getattr__(self, item):
|
||||||
"""Return instance of deferred config."""
|
"""Return instance of deferred config."""
|
||||||
return _DeferredConfig(paths=self.paths + (item,),
|
return _DeferredConfig(parents=self.parents + (item,),
|
||||||
root_config=self.root_config)
|
root_config=self.root_config)
|
||||||
|
|
||||||
def __call__(self, *args, **kwargs):
|
def __call__(self, *args, **kwargs):
|
||||||
"""Return provided instance."""
|
"""Return provided instance."""
|
||||||
return self.root_config(self.paths)
|
return self.root_config(self.parents)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user