本文整理汇总了Python中BTrees.IIBTree.IISet.__setstate__方法的典型用法代码示例。如果您正苦于以下问题:Python IISet.__setstate__方法的具体用法?Python IISet.__setstate__怎么用?Python IISet.__setstate__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BTrees.IIBTree.IISet
的用法示例。
在下文中一共展示了IISet.__setstate__方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _eval
# 需要导入模块: from BTrees.IIBTree import IISet [as 别名]
# 或者: from BTrees.IIBTree.IISet import __setstate__ [as 别名]
def _eval(query, cat):
'''evaluate *query* in the context of *cat* (a 'Products.ZCatalog.Catalog.Catalog').'''
rs = query._eval(_QueryContext(cat))
if isinstance(rs, ISearch):
if hasattr(rs, 'asSet'): rs = rs.asSet()
elif isinstance(rs, IBTree): rs = rs.getTree()
else: hits = tuple(rs); rs = IISet(); rs.__setstate__((hits,))
return rs
示例2: _build_degenerate_tree
# 需要导入模块: from BTrees.IIBTree import IISet [as 别名]
# 或者: from BTrees.IIBTree.IISet import __setstate__ [as 别名]
def _build_degenerate_tree(self):
# Build the buckets and chain them together.
from BTrees.IIBTree import IISet
from BTrees.IIBTree import IITreeSet
from BTrees.check import check
bucket11 = IISet([11])
bucket7 = IISet()
bucket7.__setstate__(((7,), bucket11))
bucket5 = IISet()
bucket5.__setstate__(((5,), bucket7))
bucket3 = IISet()
bucket3.__setstate__(((3,), bucket5))
bucket1 = IISet()
bucket1.__setstate__(((1,), bucket3))
# Build the deepest layers of indirection nodes.
ts = IITreeSet
tree1 = ts()
tree1.__setstate__(((bucket1,), bucket1))
tree3 = ts()
tree3.__setstate__(((bucket3,), bucket3))
tree5lower = ts()
tree5lower.__setstate__(((bucket5,), bucket5))
tree5 = ts()
tree5.__setstate__(((tree5lower,), bucket5))
tree7 = ts()
tree7.__setstate__(((bucket7,), bucket7))
tree11 = ts()
tree11.__setstate__(((bucket11,), bucket11))
# Paste together the middle layers.
tree13 = ts()
tree13.__setstate__(((tree1, 2, tree3), bucket1))
tree5711lower = ts()
tree5711lower.__setstate__(((tree5, 6, tree7, 10, tree11), bucket5))
tree5711 = ts()
tree5711.__setstate__(((tree5711lower,), bucket5))
# One more.
t = ts()
t.__setstate__(((tree13, 4, tree5711), bucket1))
t._check()
check(t)
return t, [1, 3, 5, 7, 11]
示例3: setOperation
# 需要导入模块: from BTrees.IIBTree import IISet [as 别名]
# 或者: from BTrees.IIBTree.IISet import __setstate__ [as 别名]
def setOperation(op, sets, isearch):
'''perform *op* on *sets*. if *isearch*, return an incremental search.
*op* may be '"and"' or '"or"'.
Uses 'IncrementalSearch', if available.
'''
if not sets:
if op == 'and': return # None means all results
if isearch: search = IOr(); search.complete(); return search
return IISet()
# Note: "multiunion" is *much* faster than "IOr"!
#if IAnd is not None and (isearch or len(sets) > 1):
if IAnd is not None and (isearch or (op == 'and' and len(sets) > 1)):
isets = []
for set in sets:
if set is None:
# all results
if op == 'and': continue
else: return
if not isinstance(set, ISearch): set = IBTree(set)
isets.append(set)
if op == 'and' and not isets: return # empty 'and'
cl = op == 'and' and IAnd or IOr
if len(isets) == 1:
# do not wrap a one element search
search = isets[0]
else: search = cl(*isets); search.complete()
if isearch: return search
if hasattr(search, 'asSet'): r = search.asSet()
else: r = IISet(); r.__setstate__((tuple(search),))
return r
if op == 'or' and len(sets) > 5:
r = multiunion(sets)
else:
combine = op == 'and' and intersection or union
r= None
for set in sets: r= combine(r,set)
if r is None:
if combine is union: r = IISet()
else: return
if isearch: r = IBTree(r)
return r