2015-03-11 13:18:42 +00:00
|
|
|
"""Utils module."""
|
|
|
|
|
2015-03-12 10:01:56 +00:00
|
|
|
from inspect import isclass
|
|
|
|
|
2015-03-11 13:18:42 +00:00
|
|
|
|
|
|
|
def is_provider(instance):
|
|
|
|
"""Check if instance is provider instance."""
|
2015-03-12 10:01:56 +00:00
|
|
|
return (not isclass(instance) and
|
|
|
|
hasattr(instance, '__IS_OBJECTS_PROVIDER__'))
|
2015-03-11 13:18:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
def is_injection(instance):
|
|
|
|
"""Check if instance is injection instance."""
|
2015-03-12 10:01:56 +00:00
|
|
|
return (not isclass(instance) and
|
|
|
|
hasattr(instance, '__IS_OBJECTS_INJECTION__'))
|
2015-03-11 13:18:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
def is_init_arg_injection(instance):
|
|
|
|
"""Check if instance is init arg injection instance."""
|
2015-03-12 10:01:56 +00:00
|
|
|
return (not isclass(instance) and
|
|
|
|
hasattr(instance, '__IS_OBJECTS_INIT_ARG_INJECTION__'))
|
2015-03-11 13:18:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
def is_attribute_injection(instance):
|
|
|
|
"""Check if instance is attribute injection instance."""
|
2015-03-12 10:01:56 +00:00
|
|
|
return (not isclass(instance) and
|
|
|
|
hasattr(instance, '__IS_OBJECTS_ATTRIBUTE_INJECTION__'))
|
2015-03-11 13:18:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
def is_method_injection(instance):
|
|
|
|
"""Check if instance is method injection instance."""
|
2015-03-12 10:01:56 +00:00
|
|
|
return (not isclass(instance) and
|
|
|
|
hasattr(instance, '__IS_OBJECTS_METHOD_INJECTION__'))
|