本文整理匯總了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