<s> """<STR_LIT>""" <EOL> import imp <EOL> import traceback <EOL> from importlib import import_module <EOL> from django . utils . six . moves import filter , map <EOL> from . compat . dj import installed_apps <EOL> def get_module ( app , modname , verbose , failfast ) : <EOL> """<STR_LIT>""" <EOL> module_name = '<STR_LIT>' % ( app , modname ) <EOL> app_mod = import_module ( app ) <EOL> try : <EOL> imp . find_module ( modname , app_mod . __path__ if hasattr ( app_mod , '<STR_LIT>' ) else None ) <EOL> except ImportError : <EOL> if failfast : <EOL> raise <EOL> elif verbose : <EOL> print ( u"<STR_LIT>" % ( modname , app ) ) <EOL> traceback . print_exc ( ) <EOL> return None <EOL> module = import_module ( module_name ) <EOL> if verbose : <EOL> print ( u"<STR_LIT>" % ( modname , app ) ) <EOL> return module <EOL> def load ( modname , verbose = False , failfast = False ) : <EOL> """<STR_LIT>""" <EOL> for app in installed_apps ( ) : <EOL> get_module ( app , modname , verbose , failfast ) <EOL> def iterload ( modname , verbose = False , failfast = False ) : <EOL> """<STR_LIT>""" <EOL> return filter ( None , ( get_module ( app , modname , verbose , failfast ) <EOL> for app in installed_apps ( ) ) ) <EOL> def load_object ( import_path ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT:.>' not in import_path : <EOL> raise TypeError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) <EOL> module_name , object_name = import_path . rsplit ( '<STR_LIT:.>' , <NUM_LIT:1> ) <EOL> module = import_module ( module_name ) <EOL> return getattr ( module , object_name ) <EOL> def iterload_objects ( import_paths ) : <EOL> """<STR_LIT>""" <EOL> return map ( load_object , import_paths ) <EOL> def get_subclasses ( c ) : <EOL> """<STR_LIT>""" <EOL> return c . __subclasses__ ( ) + sum ( map ( get_subclasses , c . __subclasses__ ( ) ) , [ ] ) <EOL> def load_from_file ( module_path ) : <EOL> """<STR_LIT>""" <EOL> from imp import load_module , PY_SOURCE <EOL> imported = None <EOL> if module_path : <EOL> with open ( module_path , '<STR_LIT:r>' ) as openfile : <EOL> imported = load_module ( "<STR_LIT>" , openfile , module_path , ( '<STR_LIT>' , '<STR_LIT:r>' , PY_SOURCE ) ) <EOL> return imported </s>
