本文整理汇总了Python中multidict.MultiDict.items方法的典型用法代码示例。如果您正苦于以下问题:Python MultiDict.items方法的具体用法?Python MultiDict.items怎么用?Python MultiDict.items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multidict.MultiDict
的用法示例。
在下文中一共展示了MultiDict.items方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: implicit_tvals
# 需要导入模块: from multidict import MultiDict [as 别名]
# 或者: from multidict.MultiDict import items [as 别名]
def implicit_tvals(self):
tvals = dict()
ret = defaultdict(NoClobberDict)
tls = self.tlayers
rls = self.rlayers
tl_n = [t.category for t in tls]
def _parse_spec(s):
c, v = s.split('=')
return (c, v.split(','))
for c in self.controls:
tvs = []
for specs, region in c.tval_specs:
wsd = MultiDict()
for w in region:
# wsd[self.values(w, rls)] = w
rv = tuple(zip([l.category for l in rls],
self.values(w, rls)))
wsd[rv] = w
for rl, ws in wsd.items():
tl_v = map(list,
map(set, zip(*[self.values(w, tls)
for w in sorted(ws)])))
assert len(tl_n) == len(tl_v)
available = zip(tl_n, tl_v)
tmp = dict(available +
map(_parse_spec, specs.split('*')))
chunk = [(tl, rl) for tl in
list(product(*[tmp[t] for t in tl_n]))]
tvs.append(chunk)
from itertools import combinations
assert 0 == sum(map(len, [set.intersection(set(x), set(y))
for x, y in list(combinations(tvs, 2))]))
for tv, rv in sorted(set(sum(tvs, []))):
ret[tv][rv] = c
return dict([(k, dict(v)) for k, v in ret.items()])