def get_loader(name): """ returns a callable associated with the specified animation loader loaders can be setup by ANIMATION_LOADERS key in the settings file default loaders are gif_loader and grid_loader :param str name: name of the loader """ try: return _MATERIALIZED_LOADERS[name] except KeyError: _, func = import_string(settings.ANIMATION_LOADERS[name]) _MATERIALIZED_LOADERS[name] = func return func
def test_import_string(): """tests if import_string loads the correct module and attribute/class""" module, func = import_string('yaff.animation.loaders.gif_loader') assert module == yaff.animation.loaders assert func == yaff.animation.loaders.gif_loader