def get_dir_pkg(d):
 parent = os.path.dirname(os.path.realpath(d))
 while ((not os.path.exists(os.path.join(d, MANIFEST_FILE))) and (not os.path.exists(os.path.join(d, PACKAGE_FILE))) and (parent != d)):
  d = parent
  parent = os.path.dirname(d)
 if (os.path.exists(os.path.join(d, MANIFEST_FILE)) or os.path.exists(os.path.join(d, PACKAGE_FILE))):
  pkg = os.path.basename(os.path.abspath(d))
  return (d, pkg)
 return (None, None)

def get_dir_pkg ( d ) : parent = os . path . dirname ( os . path . realpath ( d ) ) while ( ( not os . path . exists ( os . path . join ( d , MANIFEST_FILE ) ) ) and ( not os . path . exists ( os . path . join ( d , PACKAGE_FILE ) ) ) and ( parent != d ) ) : d = parent parent = os . path . dirname ( d ) if ( os . path . exists ( os . path . join ( d , MANIFEST_FILE ) ) or os . path . exists ( os . path . join ( d , PACKAGE_FILE ) ) ) : pkg = os . path . basename ( os . path . abspath ( d ) ) return ( d , pkg ) return ( None , None )
get the package that the directory is contained within .