Exemplo n.º 1
0
  def __handlePatchAssociatedFiles__(self):
    """ handle the info files first """
    """ first by name assiciation """
    patchInfoList = self._patchInfoDict.values()
    #handle the associated files for missingKIDSBuild info
    patchInfoList.extend(self._missKidsBuildDict.values())
    for patchInfo in patchInfoList:
      infoPath = patchInfo.kidsInfoPath
      if infoPath:
        infoName = os.path.basename(infoPath)
        associateSet = set()
        for infoFile in self._invalidInfoFileSet:
          infoFileName = os.path.basename(infoFile)
          if infoFileName.startswith(infoName[:infoName.rfind('.')]):
            patchInfo.addToAssociatedInfoList(infoFile)
            associateSet.add(infoFile)
            continue
        self._invalidInfoFileSet.difference_update(associateSet)
    """ second by mapping association """
    associateSet = set()
    for infoFile in self._invalidInfoFileSet:
      installName = getAssociatedInstallName(infoFile)
      if installName:
        if installName in self._patchInfoDict:
          patchInfo = self._patchInfoDict[installName]
        #handle the associated files for missingKIDSBuild info
        elif installName in self._missKidsBuildDict:
          patchInfo = self._missKidsBuildDict[installName]
        else:
          continue
        patchInfo.addToAssociatedInfoList(infoFile)
        associateSet.add(infoFile)
    self._invalidInfoFileSet.difference_update(associateSet)

    """ handle global files """
    associateSet = set()
    for globalFile in self._globalFilesSet:
      installName = getAssociatedInstallName(globalFile)
      if installName and installName in self._patchInfoDict:
        patchInfo = self._patchInfoDict[installName]
        patchInfo.addToAssociatedGlobalList(globalFile)
        associateSet.add(globalFile)
    self._globalFilesSet.difference_update(associateSet)

    logger.info("Total # of leftover info files: %s" %
                len(self._invalidInfoFileSet))
    logger.debug(self._invalidInfoFileSet)
    logger.info("Total # of leftover global files: %s" %
                len(self._globalFilesSet))
    logger.debug(self._globalFilesSet)
Exemplo n.º 2
0
  def __handlePatchAssociatedFiles__(self):
    """ handle the info files first """
    """ first by name assiciation """
    patchInfoList = self._patchInfoDict.values()
    #handle the associated files for missingKIDSBuild info
    patchInfoList.extend(self._missKidsBuildDict.values())
    for patchInfo in patchInfoList:
      infoPath = patchInfo.kidsInfoPath
      if infoPath:
        infoName = os.path.basename(infoPath)
        associateSet = set()
        for infoFile in self._invalidInfoFileSet:
          infoFileName = os.path.basename(infoFile)
          if infoFileName.startswith(infoName[:infoName.rfind('.')]):
            patchInfo.addToAssociatedInfoList(infoFile)
            associateSet.add(infoFile)
            continue
        self._invalidInfoFileSet.difference_update(associateSet)
    """ second by mapping association """
    associateSet = set()
    for infoFile in self._invalidInfoFileSet:
      installName = getAssociatedInstallName(infoFile)
      if installName:
        if installName in self._patchInfoDict:
          patchInfo = self._patchInfoDict[installName]
        #handle the associated files for missingKIDSBuild info
        elif installName in self._missKidsBuildDict:
          patchInfo = self._missKidsBuildDict[installName]
        else:
          continue
        patchInfo.addToAssociatedInfoList(infoFile)
        associateSet.add(infoFile)
    self._invalidInfoFileSet.difference_update(associateSet)

    """ handle global files """
    associateSet = set()
    for globalFile in self._globalFilesSet:
      installName = getAssociatedInstallName(globalFile)
      if installName and installName in self._patchInfoDict:
        patchInfo = self._patchInfoDict[installName]
        patchInfo.addToAssociatedGlobalList(globalFile)
        associateSet.add(globalFile)
    self._globalFilesSet.difference_update(associateSet)

    logger.info("Total # of leftover info files: %s" %
                len(self._invalidInfoFileSet))
    logger.debug(self._invalidInfoFileSet)
    logger.info("Total # of leftover global files: %s" %
                len(self._globalFilesSet))
    logger.debug(self._globalFilesSet)
Exemplo n.º 3
0
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)
Exemplo n.º 5
0
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)