def load_module(name, file, filename, details):
 (suffix, mode, type_) = details
 if (mode and ((not mode.startswith(('r', 'U'))) or ('+' in mode))):
  raise ValueError('invalid file open mode {!r}'.format(mode))
 elif ((file is None) and (type_ in {PY_SOURCE, PY_COMPILED})):
  msg = 'file object required for import (type code {})'.format(type_)
  raise ValueError(msg)
 elif (type_ == PY_SOURCE):
  return load_source(name, filename, file)
 elif (type_ == PY_COMPILED):
  return load_compiled(name, filename, file)
 elif ((type_ == C_EXTENSION) and (load_dynamic is not None)):
  if (file is None):
   with open(filename, 'rb') as opened_file:
    return load_dynamic(name, filename, opened_file)
  else:
   return load_dynamic(name, filename, file)
 elif (type_ == PKG_DIRECTORY):
  return load_package(name, filename)
 elif (type_ == C_BUILTIN):
  return init_builtin(name)
 elif (type_ == PY_FROZEN):
  return init_frozen(name)
 else:
  msg = "Don't know how to import {} (type code {})".format(name, type_)
  raise ImportError(msg, name=name)

def load_module ( name , file , filename , details ) : ( suffix , mode , type_ ) = details if ( mode and ( ( not mode . startswith ( ( 'r' , 'U' ) ) ) or ( '+' in mode ) ) ) : raise ValueError ( 'invalid file open mode {!r}' . format ( mode ) ) elif ( ( file is None ) and ( type_ in { PY_SOURCE , PY_COMPILED } ) ) : msg = 'file object required for import (type code {})' . format ( type_ ) raise ValueError ( msg ) elif ( type_ == PY_SOURCE ) : return load_source ( name , filename , file ) elif ( type_ == PY_COMPILED ) : return load_compiled ( name , filename , file ) elif ( ( type_ == C_EXTENSION ) and ( load_dynamic is not None ) ) : if ( file is None ) : with open ( filename , 'rb' ) as opened_file : return load_dynamic ( name , filename , opened_file ) else : return load_dynamic ( name , filename , file ) elif ( type_ == PKG_DIRECTORY ) : return load_package ( name , filename ) elif ( type_ == C_BUILTIN ) : return init_builtin ( name ) elif ( type_ == PY_FROZEN ) : return init_frozen ( name ) else : msg = "Don't know how to import {} (type code {})" . format ( name , type_ ) raise ImportError ( msg , name = name )
imports a module given its name and returns a handle to it .