def filenameToModuleName(fn):
 if isinstance(fn, bytes):
  initPy = '__init__.py'
 else:
  initPy = '__init__.py'
 fullName = os.path.abspath(fn)
 base = os.path.basename(fn)
 if (not base):
  base = os.path.basename(fn[:(-1)])
 modName = nativeString(os.path.splitext(base)[0])
 while 1:
  fullName = os.path.dirname(fullName)
  if os.path.exists(os.path.join(fullName, initPy)):
   modName = ('%s.%s' % (nativeString(os.path.basename(fullName)), nativeString(modName)))
  else:
   break
 return modName

def filenameToModuleName ( fn ) : if isinstance ( fn , bytes ) : initPy = '__init__.py' else : initPy = '__init__.py' fullName = os . path . abspath ( fn ) base = os . path . basename ( fn ) if ( not base ) : base = os . path . basename ( fn [ : ( - 1 ) ] ) modName = nativeString ( os . path . splitext ( base ) [ 0 ] ) while 1 : fullName = os . path . dirname ( fullName ) if os . path . exists ( os . path . join ( fullName , initPy ) ) : modName = ( '%s.%s' % ( nativeString ( os . path . basename ( fullName ) ) , nativeString ( modName ) ) ) else : break return modName
convert a name in the filesystem to the name of the python module it is .