def getpackage(filename):
 src_file = src(filename)
 if ((os.path.isdir(src_file) or (not src_file.endswith('.py'))) and (not ispackage(src_file))):
  return None
 (base, ext) = os.path.splitext(os.path.basename(src_file))
 if (base == '__init__'):
  mod_parts = []
 else:
  mod_parts = [base]
 (path, part) = os.path.split(os.path.split(src_file)[0])
 while part:
  if ispackage(os.path.join(path, part)):
   mod_parts.append(part)
  else:
   break
  (path, part) = os.path.split(path)
 mod_parts.reverse()
 return '.'.join(mod_parts)

def getpackage ( filename ) : src_file = src ( filename ) if ( ( os . path . isdir ( src_file ) or ( not src_file . endswith ( '.py' ) ) ) and ( not ispackage ( src_file ) ) ) : return None ( base , ext ) = os . path . splitext ( os . path . basename ( src_file ) ) if ( base == '__init__' ) : mod_parts = [ ] else : mod_parts = [ base ] ( path , part ) = os . path . split ( os . path . split ( src_file ) [ 0 ] ) while part : if ispackage ( os . path . join ( path , part ) ) : mod_parts . append ( part ) else : break ( path , part ) = os . path . split ( path ) mod_parts . reverse ( ) return '.' . join ( mod_parts )
find the full dotted package name for a given python source file name .