本文整理汇总了Python中Parsing.parseKV方法的典型用法代码示例。如果您正苦于以下问题:Python Parsing.parseKV方法的具体用法?Python Parsing.parseKV怎么用?Python Parsing.parseKV使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parsing
的用法示例。
在下文中一共展示了Parsing.parseKV方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parseKVs
# 需要导入模块: import Parsing [as 别名]
# 或者: from Parsing import parseKV [as 别名]
def parseKVs(self, kvl):
""" Convert some form of keys to an OrderedDict.
We are trying to be ridiculously flexible here. Take:
- a string, which we parse as it came from an ICC.
- a list, which we parse either as a list of key=value strings or of (key, value) duples.
"""
if isinstance(kvl, str):
return Parsing.parseKVs(kvl)
od = collections.OrderedDict()
if kvl is not None:
for i in kvl:
if isinstance(i, str):
k, v, junk = Parsing.parseKV(i)
od[k] = v
elif type(i) in (list, tuple) and len(i) == 2:
k, v, junk = Parsing.parseKV("%s=%s" % i)
else:
CPL.log('Reply', 'kvl item is not a string: %r' % (i))
raise Exception("kvl == %r" % (i))
return od