def _get_modpkg_path(dotted_name, pathlist=None):
 parts = dotted_name.split('.', 1)
 if (len(parts) > 1):
  try:
   (file, pathname, description) = imp.find_module(parts[0], pathlist)
   if file:
    file.close()
  except ImportError:
   return None
  if (description[2] == imp.PKG_DIRECTORY):
   pathname = _get_modpkg_path(parts[1], [pathname])
  else:
   pathname = None
 else:
  try:
   (file, pathname, description) = imp.find_module(dotted_name, pathlist)
   if file:
    file.close()
   if (description[2] not in [imp.PY_SOURCE, imp.PKG_DIRECTORY]):
    pathname = None
  except ImportError:
   pathname = None
 return pathname

def _get_modpkg_path ( dotted_name , pathlist = None ) : parts = dotted_name . split ( '.' , 1 ) if ( len ( parts ) > 1 ) : try : ( file , pathname , description ) = imp . find_module ( parts [ 0 ] , pathlist ) if file : file . close ( ) except ImportError : return None if ( description [ 2 ] == imp . PKG_DIRECTORY ) : pathname = _get_modpkg_path ( parts [ 1 ] , [ pathname ] ) else : pathname = None else : try : ( file , pathname , description ) = imp . find_module ( dotted_name , pathlist ) if file : file . close ( ) if ( description [ 2 ] not in [ imp . PY_SOURCE , imp . PKG_DIRECTORY ] ) : pathname = None except ImportError : pathname = None return pathname
get the filesystem path for a module or a package .