<s> import os <EOL> import glob <EOL> import imp <EOL> def find_module_path ( name ) : <EOL> '''<STR_LIT>''' <EOL> for x in [ name , "<STR_LIT>" % name , "<STR_LIT>" % name ] : <EOL> if os . path . exists ( x ) : <EOL> return x <EOL> return None <EOL> def load_modules ( dir , class_name = '<STR_LIT>' ) : <EOL> '''<STR_LIT>''' <EOL> modules = { } <EOL> for path in glob . glob ( os . path . join ( dir , '<STR_LIT>' ) ) : <EOL> ( name , ext ) = os . path . splitext ( os . path . basename ( path ) ) <EOL> if not name . startswith ( "<STR_LIT:_>" ) : <EOL> modules [ name ] = imp . load_source ( name , path ) . register ( ) <EOL> return sorted ( modules . values ( ) , key = lambda m : m . name ( ) ) </s>
