diff --git a/objects/catalog.py b/objects/catalog.py index 9c88b15a..ce8084c1 100644 --- a/objects/catalog.py +++ b/objects/catalog.py @@ -21,7 +21,7 @@ class AbstractCatalog(object): return attribute if attribute not in self.__used_providers__: - raise Error('Provider \'{}\' '.format(item) + + raise Error('Provider \'{0}\' '.format(item) + 'is not listed in dependencies') return attribute diff --git a/objects/providers.py b/objects/providers.py index 7f0c76f9..48e02c41 100644 --- a/objects/providers.py +++ b/objects/providers.py @@ -40,7 +40,7 @@ class Provider(object): try: return self.overridden[-1] except IndexError: - raise Error('Provider {} '.format(str(self)) + + raise Error('Provider {0} '.format(str(self)) + 'is not overridden') @@ -76,7 +76,7 @@ class NewInstance(Provider): """Initializer.""" if not isclass(provides): raise Error('NewInstance provider expects to get class, ' + - 'got {} instead'.format(str(provides))) + 'got {0} instead'.format(str(provides))) self.provides = provides self.init_args = tuple((injection for injection in injections @@ -160,12 +160,12 @@ class Scoped(NewInstance): del self.scopes_to_instances[scope] except KeyError: raise Error('Trying to move out of undefined scope ' - '"{}"'.format(scope)) + '"{0}"'.format(scope)) def __call__(self, *args, **kwargs): """Return provided instance.""" if not self.current_scope: - raise Error('Trying to provide {} '.format(self.provides) + + raise Error('Trying to provide {0} '.format(self.provides) + 'while provider has no active scope') try: instance = self.scopes_to_instances[self.current_scope] @@ -199,8 +199,8 @@ class ExternalDependency(Provider): instance = self.dependency.__call__(*args, **kwargs) if not isinstance(instance, self.instance_of): - raise Error('{} is not an '.format(instance) + - 'instance of {}'.format(self.instance_of)) + raise Error('{0} is not an '.format(instance) + + 'instance of {0}'.format(self.instance_of)) return instance @@ -260,7 +260,7 @@ class Callable(Provider): def __init__(self, callback, *injections): """Initializer.""" if not callable(callback): - raise Error('Callable expected, got {}'.format(str(callback))) + raise Error('Callable expected, got {0}'.format(str(callback))) self.callback = callback self.injections = tuple((injection for injection in injections @@ -314,7 +314,7 @@ class Config(Provider): value = value[path] except KeyError: raise Error('Config key ' - '"{}" is undefined'.format('.'.join(paths))) + '"{0}" is undefined'.format('.'.join(paths))) return value diff --git a/objects/utils.py b/objects/utils.py index c95d7455..1b4d438b 100644 --- a/objects/utils.py +++ b/objects/utils.py @@ -15,7 +15,7 @@ def ensure_is_provider(instance): """Check if instance is provider instance, otherwise raise and error.""" if not is_provider(instance): raise Error('Expected provider instance, ' - 'got {}'.format(str(instance))) + 'got {0}'.format(str(instance))) return instance