本文整理汇总了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
示例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