def placeToDir(infoSrc, destDir, addToGitIgnore=True): if not infoSrc or not os.path.exists(infoSrc): return infoSrcName = os.path.basename(infoSrc) infoDest = os.path.join(destDir, infoSrcName) place(infoSrc, infoDest) if addToGitIgnore and isValidSha1Suffix(infoSrcName): addToGitIgnoreList(infoDest[:infoDest.rfind('.')])
def populate(input): packages, namespaces = populatePackageMapByCSV(input) #--------------------------------------------------------------------------- # Collect all KIDS and info files under the current directory recursively #--------------------------------------------------------------------------- curDir = os.getcwd() patchOrderGen = PatchOrderGenerator() patchOrder = patchOrderGen.generatePatchOrder(curDir) patchInfoDict = patchOrderGen.getPatchInfoDict() patchInfoSet = set(patchInfoDict.keys()) patchList = patchInfoDict.values() noKidsInfoDict = patchOrderGen.getNoKidsBuildInfoDict() noKidsInfoSet = set(noKidsInfoDict.keys()) noKidsPatchList = noKidsInfoDict.values() leftoverTxtFiles = patchOrderGen.getInvalidInfoFiles() #--------------------------------------------------------------------------- # place multiBuilds KIDS Build under MultiBuilds directory #--------------------------------------------------------------------------- multiBuildSet = set([x.installName for x in patchList if x.isMultiBuilds]) for info in multiBuildSet: logger.info("Handling Multibuilds Kids %s" % info) patchInfo = patchInfoDict[info] src = patchInfo.kidsFilePath dest = os.path.normpath(os.path.join(curDir, "MultiBuilds", os.path.basename(src))) if src != dest: place(src,dest) if isValidKIDSBuildHeaderSuffix(dest): " add to ignore list if not there" addToGitIgnoreList(dest[0:dest.rfind('.')]) src = patchInfo.kidsSha1Path if not src: continue dest = os.path.normpath(os.path.join(curDir, "MultiBuilds", os.path.basename(src))) if src != dest: place(src,dest) # Map by package namespace (prefix). for ns in sorted(namespaces.keys(),order_long_to_short): path = namespaces[ns] nsPatchList = [x.installName for x in patchList if x.namespace==ns] for patch in nsPatchList: logger.info("Handling Kids %s" % patch) patchInfo = patchInfoDict[patch] patchDir = os.path.join(path, "Patches", installNameToDirName(patch)) placePatchInfo(patchInfo, curDir, patchDir) # Map KIDS Info Files that do not have associated KIDS Build Files nsNoKidsList = [x.installName for x in noKidsPatchList if x.namespace==ns] for patch in nsNoKidsList: logger.info("Handling No Kids info File %s" % patch) patchInfo = noKidsInfoDict[patch] patchDir = os.path.join(path, "Patches", installNameToDirName(patch)) placePatchInfo(patchInfo, curDir, patchDir) patchInfoSet.difference_update(nsPatchList) noKidsInfoSet.difference_update(nsNoKidsList) # Put leftover kids files in Uncategorized package. for patch in patchInfoSet: logger.info("Handling left over Kids File %s" % patch) patchInfo = patchInfoDict[patch] placePatchInfo(patchInfo, curDir, 'Uncategorized') for patch in noKidsInfoSet: logger.info("Handling left over no Kids Info File %s" % patch) patchInfo = noKidsInfoDict[patch] placePatchInfo(patchInfo, curDir, 'Uncategorized') # Put invalid kids info files in Uncategorized package. for src in leftoverTxtFiles: logger.info("Handling left over files: %s" % src) from KIDSAssociatedFilesMapping import getAssociatedInstallName installName = getAssociatedInstallName(src) if installName == "MultiBuilds": # put in Multibuilds directory dest = os.path.normpath(os.path.join(curDir, "MultiBuilds", os.path.basename(src))) if src != dest: place(src,dest) continue dirName = os.path.dirname(src) if not dirName.endswith("Packages"): logger.debug("Do not move %s" % src) continue dest = os.path.normpath(os.path.join(curDir, 'Uncategorized', os.path.basename(src))) if src != dest: place(src,dest)
def populate(input): packages_csv = csv.DictReader(input) # Parse packages and namespaces from CSV table on stdin. packages = [] pkg = None for fields in packages_csv: if fields['Package Name']: pkg = Package(fields['Package Name'], fields['Directory Name']) packages.append(pkg) if pkg: pkg.add_namespace(fields['Prefixes']) pkg.add_number(fields['File Numbers']) pkg.add_global(fields['Globals']) # Construct "namespace => path" map. namespaces = {} for p in packages: for ns in p.included: namespaces[ns] = p.path for ns in p.excluded: if not namespaces.has_key(ns): namespaces[ns] = None #--------------------------------------------------------------------------- # Collect all KIDS and info files under the current directory recursively #--------------------------------------------------------------------------- curDir = os.getcwd() kidsOrderGen = KIDSPatchOrderGenerator() patchOrder = kidsOrderGen.generatePatchOrder(curDir) patchInfoDict = kidsOrderGen.getPatchInfoDict() patchInfoSet = set(patchInfoDict.keys()) patchList = patchInfoDict.values() noKidsInfoDict = kidsOrderGen.getNoKidsBuildInfoDict() noKidsInfoSet = set(noKidsInfoDict.keys()) noKidsPatchList = noKidsInfoDict.values() leftoverTxtFiles = kidsOrderGen.getInvalidInfoFiles() #--------------------------------------------------------------------------- # place multiBuilds KIDS patch under MultiBuilds directory #--------------------------------------------------------------------------- multiBuildSet = set([x.installName for x in patchList if x.isMultiBuilds]) for info in multiBuildSet: logger.info("Handling Multibuilds Kids %s" % info) patchInfo = patchInfoDict[info] src = patchInfo.kidsFilePath dest = os.path.normpath(os.path.join(curDir, "MultiBuilds", os.path.basename(src))) if src != dest: place(src,dest) if isValidKIDSPatchHeaderSuffix(dest): " add to ignore list if not there" addToGitIgnoreList(dest[0:dest.rfind('.')]) src = patchInfo.kidsSha1Path if not src: continue dest = os.path.normpath(os.path.join(curDir, "MultiBuilds", os.path.basename(src))) if src != dest: place(src,dest) # Map by package namespace (prefix). for ns in sorted(namespaces.keys(),order_long_to_short): path = namespaces[ns] nsPatchList = [x.installName for x in patchList if x.namespace==ns] for patch in nsPatchList: logger.info("Handling Kids %s" % patch) patchInfo = patchInfoDict[patch] patchDir = os.path.join(path, "Patches", installNameToDirName(patch)) placePatchInfo(patchInfo, curDir, patchDir) # Map KIDS Info Files that do not have associated KIDS Build Files nsNoKidsList = [x.installName for x in noKidsPatchList if x.namespace==ns] for patch in nsNoKidsList: logger.info("Handling No Kids info File %s" % patch) patchInfo = noKidsInfoDict[patch] patchDir = os.path.join(path, "Patches", installNameToDirName(patch)) placePatchInfo(patchInfo, curDir, patchDir) patchInfoSet.difference_update(nsPatchList) noKidsInfoSet.difference_update(nsNoKidsList) # Put leftover kids files in Uncategorized package. for patch in patchInfoSet: logger.info("Handling left over Kids File %s" % patch) patchInfo = patchInfoDict[patch] placePatchInfo(patchInfo, curDir, 'Uncategorized') for patch in noKidsInfoSet: logger.info("Handling left over no Kids Info File %s" % patch) patchInfo = noKidsInfoDict[patch] placePatchInfo(patchInfo, curDir, 'Uncategorized') # Put invalid kids info files in Uncategorized package. for src in leftoverTxtFiles: logger.info("Handling left over files: %s" % src) from KIDSAssociatedFilesMapping import getAssociatedInstallName installName = getAssociatedInstallName(src) if installName == "MultiBuilds": # put in Multibuilds directory dest = os.path.normpath(os.path.join(curDir, "MultiBuilds", os.path.basename(src))) if src != dest: place(src,dest) continue dirName = os.path.dirname(src) if not dirName.endswith("Packages"): logger.debug("Do not move %s" % src) continue dest = os.path.normpath(os.path.join(curDir, 'Uncategorized', os.path.basename(src))) if src != dest: place(src,dest)
def populate(input): packages, namespaces = populatePackageMapByCSV(input) #--------------------------------------------------------------------------- # Collect all KIDS and info files under the current directory recursively #--------------------------------------------------------------------------- curDir = os.getcwd() patchOrderGen = PatchOrderGenerator() patchOrder = patchOrderGen.generatePatchOrder(curDir) patchInfoDict = patchOrderGen.getPatchInfoDict() patchInfoSet = set(patchInfoDict.keys()) patchList = patchInfoDict.values() noKidsInfoDict = patchOrderGen.getNoKidsBuildInfoDict() noKidsInfoSet = set(noKidsInfoDict.keys()) noKidsPatchList = noKidsInfoDict.values() leftoverTxtFiles = patchOrderGen.getInvalidInfoFiles() #--------------------------------------------------------------------------- # place multiBuilds KIDS Build under MultiBuilds directory #--------------------------------------------------------------------------- multiBuildSet = set([x.installName for x in patchList if x.isMultiBuilds]) for info in multiBuildSet: logger.info("Handling Multibuilds Kids %s" % info) patchInfo = patchInfoDict[info] src = patchInfo.kidsFilePath dest = os.path.normpath( os.path.join(curDir, "MultiBuilds", os.path.basename(src))) if src != dest: place(src, dest) if isValidKIDSBuildHeaderSuffix(dest): " add to ignore list if not there" addToGitIgnoreList(dest[0:dest.rfind('.')]) src = patchInfo.kidsSha1Path if not src: continue dest = os.path.normpath( os.path.join(curDir, "MultiBuilds", os.path.basename(src))) if src != dest: place(src, dest) # Map by package namespace (prefix). for ns in sorted(namespaces.keys(), order_long_to_short): path = namespaces[ns] nsPatchList = [x.installName for x in patchList if x.namespace == ns] for patch in nsPatchList: logger.info("Handling Kids %s" % patch) patchInfo = patchInfoDict[patch] patchDir = os.path.join(path, "Patches", installNameToDirName(patch)) placePatchInfo(patchInfo, curDir, patchDir) # Map KIDS Info Files that do not have associated KIDS Build Files nsNoKidsList = [ x.installName for x in noKidsPatchList if x.namespace == ns ] for patch in nsNoKidsList: logger.info("Handling No Kids info File %s" % patch) patchInfo = noKidsInfoDict[patch] patchDir = os.path.join(path, "Patches", installNameToDirName(patch)) placePatchInfo(patchInfo, curDir, patchDir) patchInfoSet.difference_update(nsPatchList) noKidsInfoSet.difference_update(nsNoKidsList) # Put leftover kids files in Uncategorized package. for patch in patchInfoSet: logger.info("Handling left over Kids File %s" % patch) patchInfo = patchInfoDict[patch] placePatchInfo(patchInfo, curDir, 'Uncategorized') for patch in noKidsInfoSet: logger.info("Handling left over no Kids Info File %s" % patch) patchInfo = noKidsInfoDict[patch] placePatchInfo(patchInfo, curDir, 'Uncategorized') # Put invalid kids info files in Uncategorized package. for src in leftoverTxtFiles: logger.info("Handling left over files: %s" % src) from KIDSAssociatedFilesMapping import getAssociatedInstallName installName = getAssociatedInstallName(src) if installName == "MultiBuilds": # put in Multibuilds directory dest = os.path.normpath( os.path.join(curDir, "MultiBuilds", os.path.basename(src))) if src != dest: place(src, dest) continue dirName = os.path.dirname(src) if not dirName.endswith("Packages"): logger.debug("Do not move %s" % src) continue dest = os.path.normpath( os.path.join(curDir, 'Uncategorized', os.path.basename(src))) if src != dest: place(src, dest)