parameters: (mod, subname, fullname)
return_statement: return m
docstring: m = import_submodule(mod, subname, fullname)
docstring_summary: m = import_submodule(mod, subname, fullname)
docstring_tokens: m = import_submodule ( mod subname fullname )
function: def import_submodule(mod, subname, fullname):
      """m = import_submodule(mod, subname, fullname)"""
      # Require:
      # if mod == None: subname == fullname
      # else: mod.__name__ + "." + subname == fullname
  
      global found_now
      if fullname in found_now and fullname in sys.modules:
          m = sys.modules[fullname]
      else:
          print('Reloading', fullname)
          found_now[fullname] = 1
          oldm = sys.modules.get(fullname, None)
  
          if mod is None:
              path = None
          elif hasattr(mod, '__path__'):
              path = mod.__path__
          else:
              return None
  
          try:
              # This appears to be necessary on Python 3, because imp.find_module()
              # tries to import standard libraries (like io) itself, and we don't
              # want them to be processed by our deep_import_hook.
              with replace_import_hook(original_import):
                  fp, filename, stuff = imp.find_module(subname, path)
          except ImportError:
              return None
  
          try:
              m = imp.load_module(fullname, fp, filename, stuff)
          except:
              # load_module probably removed name from modules because of
              # the error.  Put back the original module object.
              if oldm:
                  sys.modules[fullname] = oldm
              raise
          finally:
              if fp: fp.close()
  
          add_submodule(mod, m, fullname, subname)
  
      return m
function_tokens: def import_submodule ( mod , subname , fullname ) : # Require: # if mod == None: subname == fullname # else: mod.__name__ + "." + subname == fullname global found_now if fullname in found_now and fullname in sys . modules : m = sys . modules [ fullname ] else : print ( 'Reloading' , fullname ) found_now [ fullname ] = 1 oldm = sys . modules . get ( fullname , None ) if mod is None : path = None elif hasattr ( mod , '__path__' ) : path = mod . __path__ else : return None try : # This appears to be necessary on Python 3, because imp.find_module() # tries to import standard libraries (like io) itself, and we don't # want them to be processed by our deep_import_hook. with replace_import_hook ( original_import ) : fp , filename , stuff = imp . find_module ( subname , path ) except ImportError : return None try : m = imp . load_module ( fullname , fp , filename , stuff ) except : # load_module probably removed name from modules because of # the error.  Put back the original module object. if oldm : sys . modules [ fullname ] = oldm raise finally : if fp : fp . close ( ) add_submodule ( mod , m , fullname , subname ) return m