def modpath_from_file(filename, extrapath=None):
 base = splitext(abspath(filename))[0]
 if (extrapath is not None):
  for path_ in extrapath:
   path = abspath(path_)
   if (path and (base[:len(path)] == path)):
    submodpath = [pkg for pkg in base[len(path):].split(os.sep) if pkg]
    if _check_init(path, submodpath[:(-1)]):
     return (extrapath[path_].split('.') + submodpath)
 for path in sys.path:
  path = abspath(path)
  if (path and base.startswith(path)):
   modpath = [pkg for pkg in base[len(path):].split(os.sep) if pkg]
   if _check_init(path, modpath[:(-1)]):
    return modpath
 raise ImportError(('Unable to find module for %s in %s' % (filename, ', \n'.join(sys.path))))

def modpath_from_file ( filename , extrapath = None ) : base = splitext ( abspath ( filename ) ) [ 0 ] if ( extrapath is not None ) : for path_ in extrapath : path = abspath ( path_ ) if ( path and ( base [ : len ( path ) ] == path ) ) : submodpath = [ pkg for pkg in base [ len ( path ) : ] . split ( os . sep ) if pkg ] if _check_init ( path , submodpath [ : ( - 1 ) ] ) : return ( extrapath [ path_ ] . split ( '.' ) + submodpath ) for path in sys . path : path = abspath ( path ) if ( path and base . startswith ( path ) ) : modpath = [ pkg for pkg in base [ len ( path ) : ] . split ( os . sep ) if pkg ] if _check_init ( path , modpath [ : ( - 1 ) ] ) : return modpath raise ImportError ( ( 'Unable to find module for %s in %s' % ( filename , ', \n' . join ( sys . path ) ) ) )
given a file path return the corresponding splitted modules name :type filename: str .