Skip to content

Commit

Permalink
mrclean
Browse files Browse the repository at this point in the history
  • Loading branch information
akatrevorjay committed Jan 2, 2017
1 parent aa952ec commit 8843c49
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
5 changes: 1 addition & 4 deletions mainline/catalog.py
Expand Up @@ -68,10 +68,7 @@ def __new__(mcs, class_name, bases, attributes):
else:
cls._providers = mcs._provider_mapping_factory()

cls._providers.update(
{k: v for k, v in six.iteritems(attributes)
if isinstance(v, IProvider)}
)
cls._providers.update({k: v for k, v in six.iteritems(attributes) if isinstance(v, IProvider)})

return cls

Expand Down
5 changes: 5 additions & 0 deletions mainline/injection.py
Expand Up @@ -15,6 +15,7 @@


class Injector(object):

def __init__(self, di):
self.di = di

Expand All @@ -26,6 +27,7 @@ def decorate(self, wrapped):


class CallableInjector(Injector):

def __init__(self, di, *args, **kwargs):
super(CallableInjector, self).__init__(di)
self.args = args
Expand Down Expand Up @@ -56,6 +58,7 @@ def __call__(self, wrapped):


class SpecInjector(CallableInjector):

def decorate(self, wrapped):
# Remove the number of args from the wrapped function's argspec
spec = getargspec(wrapped)
Expand All @@ -80,6 +83,7 @@ def decorator(wrapped, instance, args, kwargs):


class AutoSpecInjector(CallableInjector):

def decorate(self, wrapped):
spec = getargspec(wrapped)

Expand Down Expand Up @@ -119,6 +123,7 @@ def decorator(*args, **kwargs):


class ClassPropertyInjector(Injector):

def __init__(self, di, key, name=None, replace_on_access=False):
super(ClassPropertyInjector, self).__init__(di)
self.key = key
Expand Down
6 changes: 3 additions & 3 deletions mainline/provider.py
Expand Up @@ -6,6 +6,7 @@


class IProvider(object):

def __init__(self):
pass

Expand All @@ -27,6 +28,7 @@ def providable(self):


class IFactoryProvider(IProvider):

def __init__(self, factory=None):
self.set_factory(factory)

Expand Down Expand Up @@ -58,9 +60,7 @@ def __init__(self, factory, scope=NoneScope, key=''):
super(Provider, self).__init__(factory)

def __repr__(self):
return '<%s factory=%s scope=%s>' % (self.__class__.__name__,
self.factory,
self.scope)
return '<%s factory=%s scope=%s>' % (self.__class__.__name__, self.factory, self.scope)

def provide(self, *args, **kwargs):
if self.has_instance():
Expand Down
2 changes: 2 additions & 0 deletions mainline/scope.py
Expand Up @@ -91,12 +91,14 @@ def instances_factory(self):


class ProxyScope(IScope):

def __init__(self, scope, *args, **kwargs):
self.instances = scope
super(ProxyScope, self).__init__(*args, **kwargs)


class NamespacedProxyScope(ProxyScope):

def __init__(self, namespace, scope, *args, **kwargs):
self.namespace = namespace
super(NamespacedProxyScope, self).__init__(scope, *args, **kwargs)
Expand Down
2 changes: 2 additions & 0 deletions mainline/utils.py
Expand Up @@ -15,6 +15,7 @@ def _get_object_init():


class classproperty(object):

def __init__(self, f):
self.f = f

Expand All @@ -23,6 +24,7 @@ def __get__(self, obj, owner):


class ProxyMutableMapping(collections.MutableMapping):

def __init__(self, mapping):
self.__mapping = mapping

Expand Down

0 comments on commit 8843c49

Please sign in to comment.