<s> from __future__ import unicode_literals <EOL> import imp <EOL> import importlib <EOL> import inspect <EOL> from django . conf import settings <EOL> def get_module ( app , modname ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> app_path = importlib . import_module ( app ) . __path__ <EOL> except AttributeError : <EOL> return <EOL> try : <EOL> imp . find_module ( modname , app_path ) <EOL> except ImportError : <EOL> return <EOL> importlib . import_module ( '<STR_LIT>' . format ( app , modname ) ) <EOL> def load ( modname ) : <EOL> """<STR_LIT>""" <EOL> for app in settings . INSTALLED_APPS : <EOL> get_module ( app , modname ) <EOL> def get_subclasses ( mod , cls ) : <EOL> """<STR_LIT>""" <EOL> for name , obj in inspect . getmembers ( mod ) : <EOL> if obj != cls and inspect . isclass ( obj ) and issubclass ( obj , cls ) : <EOL> yield obj </s>
