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


Python StringUtils.getStringInConditionalBrackets方法代码示例

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


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

示例1: _readDependentPackageData

# 需要导入模块: from StringUtils import StringUtils [as 别名]
# 或者: from StringUtils.StringUtils import getStringInConditionalBrackets [as 别名]
    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,代码行数:36,代码来源:SpecParser.py

示例2: _readDependentPackageData

# 需要导入模块: from StringUtils import StringUtils [as 别名]
# 或者: from StringUtils.StringUtils import getStringInConditionalBrackets [as 别名]
    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,代码行数:46,代码来源:SpecParser.py


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