当前位置: 首页>>代码示例>>Python>>正文


Python StringUtils.StringUtils类代码示例

本文整理汇总了Python中StringUtils.StringUtils的典型用法代码示例。如果您正苦于以下问题:Python StringUtils类的具体用法?Python StringUtils怎么用?Python StringUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了StringUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _readDependentPackageData

    def _readDependentPackageData(self, line):
        strUtils = StringUtils()
        listPackages = line.split(",")
        listdependentpkgs = []
        for line in listPackages:
            line = strUtils.getStringInConditionalBrackets(line)
            listContents = line.split()
            totalContents = len(listContents)
            i = 0
            while i < totalContents:
                dpkg = dependentPackageData()
                compare = None
                packageName = listContents[i]
                if listContents[i].startswith("/"):
                    provider = constants.providedBy.get(listContents[i], None)
                    if provider is not None:
                        packageName = provider
                    else:
                        raise Exception('What package does provide %s? Please modify providedBy in constants.py' % (listContents[i]))
                    i += 1
                if i + 2 < len(listContents):
                    if listContents[i+1] in (">=", "<=", "=", "<", ">"):
                        compare = listContents[i+1]

                if compare is not None:
                    dpkg.package = packageName
                    dpkg.compare = compare
                    dpkg.version = listContents[i+2]
                    i = i + 3
                else:
                    dpkg.package = packageName
                    i = i + 1
                listdependentpkgs.append(dpkg)
        return listdependentpkgs
开发者ID:frapposelli,项目名称:photon,代码行数:34,代码来源:SpecParser.py

示例2: readChecksum

 def readChecksum(self,line,pkg):
     strUtils = StringUtils()
     line=pkg.decodeContents(line)
     data = line.strip();
     words=data.split(" ")
     nrWords = len(words)
     if (nrWords != 3):
         print "Error: Unable to parse line: "+line
         return False
     value=words[2].split("=")
     if (len(value) != 2):
         print "Error: Unable to parse line: "+line
         return False
     matchedSources=[]
     for source in pkg.sources:
         sourceName=strUtils.getFileNameFromURL(source)
         if (sourceName.startswith(value[0])):
             matchedSources.append(sourceName)
     if (len(matchedSources) == 0):
         print "Error: Can not find match for sha1 "+value[0]
         return False
     if (len(matchedSources) > 1):
         print "Error: Too many matches in sources: "+matchedSources+" for sha1 "+value[0]
         return False
     pkg.checksums[sourceName] = value[1]
     return True;
开发者ID:DheerajSShetty,项目名称:photon,代码行数:26,代码来源:SpecParser.py

示例3: _readChecksum

 def _readChecksum(self, line, pkg):
     strUtils = StringUtils()
     line = self._replaceMacros(line)
     data = line.strip()
     words = data.split()
     nrWords = len(words)
     if nrWords != 3:
         print("Error: Unable to parse line: " + line)
         return False
     value = words[2].split("=")
     if len(value) != 2:
         print("Error: Unable to parse line: "+line)
         return False
     matchedSources = []
     for source in pkg.sources:
         sourceName = strUtils.getFileNameFromURL(source)
         if sourceName.startswith(value[0]):
             matchedSources.append(sourceName)
     if not matchedSources:
         print("Error: Can not find match for sha1 " + value[0])
         return False
     if len(matchedSources) > 1:
         print("Error: Too many matched Sources:" +
               ' '.join(matchedSources) + " for sha1 " + value[0])
         return False
     pkg.checksums[sourceName] = value[1]
     return True
开发者ID:TiejunChina,项目名称:photon,代码行数:27,代码来源:SpecParser.py

示例4: buildSourcesList

def buildSourcesList(specPath, yamlDir, singleFile=False):
    strUtils = StringUtils()
    if singleFile:
        yamlFile = open(yamlDir+"sources_list.yaml", "w")
    lst = os.listdir(specPath)
    lst.sort()
    for dirEntry in lst:
        specDir = os.path.join(specPath, dirEntry)
        if os.path.isdir(specDir):
            for specEntry in os.listdir(specDir):
                specFile = os.path.join(specDir, specEntry)
                if os.path.isfile(specFile) and specFile.endswith(".spec"):
                    spec=Specutils(specFile)
                    modified = len(spec.getPatchNames()) > 0
                    ss=spec.getSourceURLs()
                    for s in ss:
                        if (s.startswith("http") or s.startswith("ftp")):
                            ossname=strUtils.getPackageNameFromURL(s)
                            ossversion=strUtils.getPackageVersionFromURL(s)
                            if not singleFile:
                                yamlFile = open(yamlDir+ossname+"-"+ossversion+".yaml", "w")
                            yamlFile.write("vmwsource:"+ossname+":"+ossversion+":\n")
                            yamlFile.write("  repository: VMWsource\n")
                            yamlFile.write("  name: '"+ossname+"'\n")
                            yamlFile.write("  version: '"+ossversion+"'\n")
                            yamlFile.write("  url: "+s+"\n")
                            yamlFile.write("  license: UNKNOWN\n")
                            if modified:
                                yamlFile.write("  modified: true\n")
                            yamlFile.write("\n")
                            if not singleFile:
                                yamlFile.close()
    if singleFile:
        yamlFile.close()
开发者ID:sabertail,项目名称:photon,代码行数:34,代码来源:builder.py

示例5: _getPatchNames

 def _getPatchNames(self):
     patchNames = []
     strUtils = StringUtils()
     pkg = self.packages.get('default')
     for patch in pkg.patches:
         patchName = strUtils.getFileNameFromURL(patch)
         patchNames.append(patchName)
     return patchNames
开发者ID:frapposelli,项目名称:photon,代码行数:8,代码来源:SpecParser.py

示例6: _getSourceNames

 def _getSourceNames(self):
     sourceNames = []
     strUtils = StringUtils()
     pkg = self.packages.get('default')
     for source in pkg.sources:
         sourceName = strUtils.getFileNameFromURL(source)
         sourceNames.append(sourceName)
     return sourceNames
开发者ID:frapposelli,项目名称:photon,代码行数:8,代码来源:SpecParser.py

示例7: getSourceNames

 def getSourceNames(self):
     sourceNames = []
     strUtils = StringUtils()
     pkg = self.spec.packages.get("default")
     if pkg is None:
         return None
     for source in pkg.sources:
         sourceName = strUtils.getFileNameFromURL(source)
         sourceNames.append(sourceName)
     return sourceNames
开发者ID:casualjim,项目名称:photon,代码行数:10,代码来源:SpecUtils.py

示例8: getPatchNames

 def getPatchNames(self):
     patchNames = []
     strUtils = StringUtils()
     pkg = self.spec.packages.get("default")
     if pkg is None:
         return None
     for patch in pkg.patches:
         patchName = strUtils.getFileNameFromURL(patch)
         patchNames.append(patchName)
     return patchNames
开发者ID:casualjim,项目名称:photon,代码行数:10,代码来源:SpecUtils.py

示例9: _buildPackage

    def _buildPackage(self):
        try:
            self.sandbox.create(self.package + "-" + self.version)

            tUtils = ToolChainUtils(self.logName, self.logPath)
            if self.sandbox.hasToolchain():
                tUtils.installExtraToolchainRPMS(self.sandbox, self.package, self.version)
            else:
                tUtils.installToolchainRPMS(self.sandbox, self.package, self.version, availablePackages=self.doneList)

            listDependentPackages, listTestPackages, listInstalledPackages, listInstalledRPMs = (
                self._findDependentPackagesAndInstalledRPM(self.sandbox))

            pkgUtils = PackageUtils(self.logName, self.logPath)

            if listDependentPackages:
                self.logger.debug("Installing the build time dependent packages......")
                for pkg in listDependentPackages:
                    packageName, packageVersion = StringUtils.splitPackageNameAndVersion(pkg)
                    self._installPackage(pkgUtils, packageName, packageVersion, self.sandbox, self.logPath,listInstalledPackages, listInstalledRPMs)
                for pkg in listTestPackages:
                    flag = False
                    packageName, packageVersion = StringUtils.splitPackageNameAndVersion(pkg)
                    for depPkg in listDependentPackages:
                        depPackageName, depPackageVersion = StringUtils.splitPackageNameAndVersion(depPkg)
                        if depPackageName == packageName:
                            flag = True
                            break;
                    if flag == False:
                        self._installPackage(pkgUtils, packageName,packageVersion, self.sandbox, self.logPath,listInstalledPackages, listInstalledRPMs)
                pkgUtils.installRPMSInOneShot(self.sandbox)
                self.logger.debug("Finished installing the build time dependent packages....")

            pkgUtils.adjustGCCSpecs(self.sandbox, self.package, self.version)
            pkgUtils.buildRPMSForGivenPackage(self.sandbox, self.package, self.version,
                                              self.logPath)
            self.logger.debug("Successfully built the package: " + self.package)
        except Exception as e:
            self.logger.error("Failed while building package: " + self.package)
            self.logger.debug("Sandbox: " + self.sandbox.getID() +
                              " not deleted for debugging.")
            logFileName = os.path.join(self.logPath, self.package + ".log")
            fileLog = os.popen('tail -n 100 ' + logFileName).read()
            self.logger.info(fileLog)
            raise e
        if self.sandbox:
            self.sandbox.destroy()
开发者ID:frapposelli,项目名称:photon,代码行数:47,代码来源:PackageBuilder.py

示例10: _readDependentPackageData

    def _readDependentPackageData(self, line):
        strUtils = StringUtils()
        listPackages = line.split(",")
        listdependentpkgs = []
        for line in listPackages:
            line = strUtils.getStringInConditionalBrackets(line)
            listContents = line.split()
            totalContents = len(listContents)
            i = 0
            while i < totalContents:
                dpkg = dependentPackageData()
                compare = None
                packageName = listContents[i]
                if listContents[i].startswith("/"):
                    provider = constants.providedBy.get(listContents[i], None)
                    i += 1
                    if provider is not None:
                        packageName = provider
                    else:
                        continue
                if i + 2 < len(listContents):
                    if listContents[i+1] == ">=":
                        compare = "gte"
                    elif listContents[i+1] == "<=":
                        compare = "lte"
                    elif listContents[i+1] == "==":
                        compare = "eq"
                    elif listContents[i+1] == "<":
                        compare = "lt"
                    elif listContents[i+1] == ">":
                        compare = "gt"
                    elif listContents[i+1] == "=":
                        compare = "eq"

                if compare is not None:
                    dpkg.package = packageName
                    dpkg.compare = compare
                    dpkg.version = listContents[i+2]
                    i = i + 3
                else:
                    dpkg.package = packageName
                    i = i + 1
                listdependentpkgs.append(dpkg)
        return listdependentpkgs
开发者ID:TiejunChina,项目名称:photon,代码行数:44,代码来源:SpecParser.py

示例11: _getWeight

    def _getWeight(package):
	# Package weights are assumed to be independent of package
	# version (i.e., in the case of multi-version packages such as
	# Go or Kubernetes, all the versions have the same weight). So
	# convert packageName-version to packageName before looking up
	# the package weight.
        package, _ = StringUtils.splitPackageNameAndVersion(package)
        try:
            return int(Scheduler.pkgWeights[package]) + 1
        except KeyError:
            return 1
开发者ID:frapposelli,项目名称:photon,代码行数:11,代码来源:Scheduler.py

示例12: readDependentPackageData

 def readDependentPackageData(self,line):
     strUtils = StringUtils()
     listPackages=line.split(",")
     listdependentpkgs=[]
     for line in listPackages:
         line=strUtils.getStringInBrackets(line)
         listContents=line.split()
         totalContents = len(listContents)
         i=0
         while i < totalContents:
             dpkg = dependentPackageData()
             compare=None
             if listContents[i].startswith("/"):
                 i=i+1
                 continue
             if i+2 < len(listContents):
                 if listContents[i+1] == ">=":
                     compare="gte"
                 elif listContents[i+1] == "<=":
                     compare="lte"
                 elif listContents[i+1] == "==":
                     compare="eq"
                 elif listContents[i+1] == "<":
                     compare="lt"
                 elif listContents[i+1] == ">":
                     compare="gt"
                 elif listContents[i+1] == "=":
                     compare="eq"
                 
             if compare is not None:
                 dpkg.package=listContents[i]
                 dpkg.compare=compare
                 dpkg.version=listContents[i+2]
                 i=i+3
             else:
                 dpkg.package=listContents[i]
                 i=i+1
             listdependentpkgs.append(dpkg)
     return listdependentpkgs
开发者ID:megacoder,项目名称:photon,代码行数:39,代码来源:SpecParser.py

示例13: _installDependentRunTimePackages

 def _installDependentRunTimePackages(self, pkgUtils, package, packageVersion, sandbox, destLogPath,
                                      listInstalledPackages, listInstalledRPMs):
     listRunTimeDependentPackages = self._findRunTimeRequiredRPMPackages(package, packageVersion)
     if listRunTimeDependentPackages:
         for pkg in listRunTimeDependentPackages:
             if pkg in self.mapPackageToCycles:
                 continue
             packageName, packageVersion = StringUtils.splitPackageNameAndVersion(pkg)
             rpmfile = pkgUtils.findRPMFile(packageName, packageVersion)
             if rpmfile is None:
                 self.logger.error("No rpm file found for package: " + packageName + "-" + packageVersion)
                 raise Exception("Missing rpm file")
             latestPkgRPM = os.path.basename(rpmfile).replace(".rpm", "")
             if pkg in listInstalledPackages and latestPkgRPM in listInstalledRPMs:
                 continue
             self._installPackage(pkgUtils, packageName,packageVersion, sandbox, destLogPath,listInstalledPackages, listInstalledRPMs)
开发者ID:frapposelli,项目名称:photon,代码行数:16,代码来源:PackageBuilder.py

示例14: build

    def build(self, pkg, doneList):
        packageName, packageVersion = StringUtils.splitPackageNameAndVersion(pkg)
        #do not build if RPM is already built
        #test only if the package is in the testForceRPMS with rpmCheck
        #build only if the package is not in the testForceRPMS with rpmCheck

        if not constants.rpmCheck or packageName in constants.testForceRPMS:
            if self._checkIfPackageIsAlreadyBuilt(packageName, packageVersion, doneList):
                return

        self._buildPackagePrepareFunction(packageName, packageVersion, doneList)
        try:
            self._buildPackage()
        except Exception as e:
            # TODO: self.logger might be None
            self.logger.exception(e)
            raise e
开发者ID:frapposelli,项目名称:photon,代码行数:17,代码来源:PackageBuilder.py

示例15: _createGraphNodes

    def _createGraphNodes():

        # GRAPH-BUILD STEP 1: Initialize graph nodes for each package.
        #
        # Create a graph with a node to represent every package and all
        # its dependent packages in the given list.
        for package in Scheduler.sortedList:
            packageName, packageVersion = StringUtils.splitPackageNameAndVersion(package)
            node = DependencyGraphNode(packageName, packageVersion,
                                       Scheduler._getWeight(package))
            Scheduler.mapPackagesToGraphNodes[package] = node

        for package in Scheduler.sortedList:
            pkgNode = Scheduler.mapPackagesToGraphNodes[package]
            for childPackage in Scheduler._getBuildRequiredPackages(package):
                childPkgNode = Scheduler.mapPackagesToGraphNodes[childPackage]
                pkgNode.buildRequiresPkgNodes.add(childPkgNode)

            for childPackage in Scheduler._getRequiredPackages(package):
                childPkgNode = Scheduler.mapPackagesToGraphNodes[childPackage]
                pkgNode.installRequiresPkgNodes.add(childPkgNode)

        # GRAPH-BUILD STEP 2: Mark package dependencies in the graph.
        #
        # Add parent-child relationships between dependent packages.
        # If a package 'A' build-requires or install-requires package 'B', then:
        #   - Mark 'B' as a child of 'A' in the graph.
        #   - Mark 'A' as a parent of 'B' in the graph.
        #
        #                     A
        #
        #                  /     \
        #                 v       v
        #
        #                B         C
        #
        for package in Scheduler.sortedList:
            pkgNode = Scheduler.mapPackagesToGraphNodes[package]
            for childPkgNode in pkgNode.buildRequiresPkgNodes:
                pkgNode.childPkgNodes.add(childPkgNode)
                childPkgNode.parentPkgNodes.add(pkgNode)

            for childPkgNode in pkgNode.installRequiresPkgNodes:
                pkgNode.childPkgNodes.add(childPkgNode)
                childPkgNode.parentPkgNodes.add(pkgNode)
开发者ID:frapposelli,项目名称:photon,代码行数:45,代码来源:Scheduler.py


注:本文中的StringUtils.StringUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。