# Path: auxlib/compat.py
# def isiterable(obj):
# 
# Path: auxlib/exceptions.py
# class InitializationError(AuxlibError, EnvironmentError):
#     pass


from .compat import with_metaclass
from .exceptions import InitializationError
        if 'skip_registration' in cls.__dict__ and cls.skip_registration:
            pass  # we don't even care  # pragma: no cover
        elif cls.factory is None:
            # this must be the base implementation; add a factory object
            cls.factory = type(cls.__name__ + 'Factory', (FactoryBase, ),
                               {'providers': dict(), 'cache': dict()})
            if hasattr(cls, 'gateways'):
                cls.gateways.add(cls)
        else:
            # must be a derived object, register it as a provider in cls.factory
            cls.factory.providers[cls.__name__] = cls

    def __call__(cls, *args):
        if 'factory' in cls.__dict__:
            if args and args[0]:
                return cls.factory.get_instance(args[0])
            else:
                return cls.factory.get_instance()
        else:
            if not getattr(cls, 'do_cache', False):
                return super(FactoryType, cls).__call__(*args)
            cache_id = "{0}".format(cls.__name__)
            try:
                return cls.factory.cache[cache_id]
            except KeyError:
                instance = super(FactoryType, cls).__call__(*args)
                cls.factory.cache[cache_id] = instance
                return instance



# Path: auxlib/compat.py
# def isiterable(obj):
# 
# Path: auxlib/exceptions.py
# class InitializationError(AuxlibError, EnvironmentError):
#     pass


# Path: auxlib/factory.py
from .compat import with_metaclass
from .exceptions import InitializationError

        if 'skip_registration' in cls.__dict__ and cls.skip_registration:
            pass  # we don't even care  # pragma: no cover
        elif cls.factory is None:
            # this must be the base implementation; add a factory object
            cls.factory = type(cls.__name__ + 'Factory', (FactoryBase, ),
                               {'providers': dict(), 'cache': dict()})
            if hasattr(cls, 'gateways'):
                cls.gateways.add(cls)
        else:
            # must be a derived object, register it as a provider in cls.factory
            cls.factory.providers[cls.__name__] = cls

    def __call__(cls, *args):
        if 'factory' in cls.__dict__:
            if args and args[0]:
                return cls.factory.get_instance(args[0])
            else:
                return cls.factory.get_instance()
        else:
            if not getattr(cls, 'do_cache', False):
                return super(FactoryType, cls).__call__(*args)
            cache_id = "{0}".format(cls.__name__)
            try:
                return cls.factory.cache[cache_id]
            except KeyError:
                instance = super(FactoryType, cls).__call__(*args)
                cls.factory.cache[cache_id] = instance
                return instance



@with_metaclass(FactoryType)