<s> import imp <EOL> from os import listdir <EOL> from os . path import dirname , splitext <EOL> from django . template import loaders <EOL> MODULE_EXTENSIONS = tuple ( [ suffix [ <NUM_LIT:0> ] for suffix in imp . get_suffixes ( ) ] ) <EOL> def get_django_template_loaders ( ) : <EOL> return [ ( loader . __name__ . rsplit ( '<STR_LIT:.>' , <NUM_LIT:1> ) [ <NUM_LIT:1> ] , loader ) <EOL> for loader in get_submodules ( loaders ) <EOL> if hasattr ( loader , '<STR_LIT>' ) ] <EOL> def get_submodules ( package ) : <EOL> submodules = ( "<STR_LIT>" % ( package . __name__ , module ) <EOL> for module in package_contents ( package ) ) <EOL> return [ __import__ ( module , { } , { } , [ module . rsplit ( "<STR_LIT:.>" , <NUM_LIT:1> ) [ - <NUM_LIT:1> ] ] ) <EOL> for module in submodules ] <EOL> def package_contents ( package ) : <EOL> package_path = dirname ( loaders . __file__ ) <EOL> return set ( [ splitext ( module ) [ <NUM_LIT:0> ] <EOL> for module in listdir ( package_path ) <EOL> if module . endswith ( MODULE_EXTENSIONS ) ] ) </s>
