當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。