Commit d00b5907 authored by Tres Seaver's avatar Tres Seaver

Expose the XXTreeIterator.

Note that the Python version exists only for BBB:  no application code
should instantiate one directly.
parent 9fb7e16f
......@@ -28,6 +28,7 @@ from ._base import MERGE_DEFAULT_float
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
......@@ -76,6 +77,10 @@ class IFTreeSetPy(TreeSet):
MERGE_DEFAULT = MERGE_DEFAULT_float
class IFTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
IFBucketPy._mapping_type = IFBucketPy._bucket_type = IFBucketPy
......@@ -105,6 +110,7 @@ except ImportError: #pragma NO COVER w/ C extensions
IFSet = IFSetPy
IFBTree = IFBTreePy
IFTreeSet = IFTreeSetPy
IFTreeIterator = IFTreeIteratorPy
difference = differencePy
union = unionPy
intersection = intersectionPy
......@@ -115,6 +121,7 @@ else: #pragma NO COVER w/o C extensions
from ._IFBTree import IFSet
from ._IFBTree import IFBTree
from ._IFBTree import IFTreeSet
from ._IFBTree import IFTreeIterator
from ._IFBTree import difference
from ._IFBTree import union
from ._IFBTree import intersection
......
......@@ -28,6 +28,7 @@ from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
......@@ -77,6 +78,10 @@ class IITreeSetPy(TreeSet):
MERGE_DEFAULT = MERGE_DEFAULT_int
class IITreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
IIBucketPy._mapping_type = IIBucketPy._bucket_type = IIBucketPy
......@@ -106,6 +111,7 @@ except ImportError: #pragma NO COVER w/ C extensions
IISet = IISetPy
IIBTree = IIBTreePy
IITreeSet = IITreeSetPy
IITreeIterator = IITreeIteratorPy
difference = differencePy
union = unionPy
intersection = intersectionPy
......@@ -116,6 +122,7 @@ else: #pragma NO COVER w/o C extensions
from ._IIBTree import IISet
from ._IIBTree import IIBTree
from ._IIBTree import IITreeSet
from ._IIBTree import IITreeIterator
from ._IIBTree import difference
from ._IIBTree import union
from ._IIBTree import intersection
......
......@@ -25,6 +25,7 @@ from ._base import MERGE_WEIGHT_default
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
......@@ -61,6 +62,9 @@ class IOTreeSetPy(TreeSet):
MAX_SIZE = _TREE_SIZE
_to_key = _to_key
class IOTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
......@@ -89,6 +93,7 @@ except ImportError: #pragma NO COVER w/ C extensions
IOSet = IOSetPy
IOBTree = IOBTreePy
IOTreeSet = IOTreeSetPy
IOTreeIterator = IOTreeIteratorPy
difference = differencePy
union = unionPy
intersection = intersectionPy
......@@ -97,6 +102,7 @@ else: #pragma NO COVER w/o C extensions
from ._IOBTree import IOSet
from ._IOBTree import IOBTree
from ._IOBTree import IOTreeSet
from ._IOBTree import IOTreeIterator
from ._IOBTree import difference
from ._IOBTree import union
from ._IOBTree import intersection
......
......@@ -28,6 +28,7 @@ from ._base import MERGE_DEFAULT_float
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
......@@ -77,6 +78,10 @@ class LFTreeSetPy(TreeSet):
MERGE_DEFAULT = MERGE_DEFAULT_float
class LFTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
LFBucketPy._mapping_type = LFBucketPy._bucket_type = LFBucketPy
......@@ -106,6 +111,7 @@ except ImportError: #pragma NO COVER w/ C extensions
LFSet = LFSetPy
LFBTree = LFBTreePy
LFTreeSet = LFTreeSetPy
LFTreeIterator = LFTreeIteratorPy
difference = differencePy
union = unionPy
intersection = intersectionPy
......@@ -116,6 +122,7 @@ else: #pragma NO COVER w/o C extensions
from ._LFBTree import LFSet
from ._LFBTree import LFBTree
from ._LFBTree import LFTreeSet
from ._LFBTree import LFTreeIterator
from ._LFBTree import difference
from ._LFBTree import union
from ._LFBTree import intersection
......
......@@ -28,6 +28,7 @@ from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
......@@ -77,6 +78,10 @@ class LLTreeSetPy(TreeSet):
MERGE_DEFAULT = MERGE_DEFAULT_int
class LLTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
LLBucketPy._mapping_type = LLBucketPy._bucket_type = LLBucketPy
......@@ -106,6 +111,7 @@ except ImportError: #pragma NO COVER w/ C extensions
LLSet = LLSetPy
LLBTree = LLBTreePy
LLTreeSet = LLTreeSetPy
LLTreeIterator = LLTreeIteratorPy
difference = differencePy
union = unionPy
intersection = intersectionPy
......@@ -116,6 +122,7 @@ else: #pragma NO COVER w/o C extensions
from ._LLBTree import LLSet
from ._LLBTree import LLBTree
from ._LLBTree import LLTreeSet
from ._LLBTree import LLTreeIterator
from ._LLBTree import difference
from ._LLBTree import union
from ._LLBTree import intersection
......
......@@ -25,6 +25,7 @@ from ._base import MERGE_WEIGHT_default
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
......@@ -62,6 +63,10 @@ class LOTreeSetPy(TreeSet):
_to_key = _to_key
class LOTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
LOBucketPy._mapping_type = LOBucketPy._bucket_type = LOBucketPy
......@@ -89,6 +94,7 @@ except ImportError: #pragma NO COVER w/ C extensions
LOSet = LOSetPy
LOBTree = LOBTreePy
LOTreeSet = LOTreeSetPy
LOTreeIterator = LOTreeIteratorPy
difference = differencePy
union = unionPy
intersection = intersectionPy
......@@ -97,6 +103,7 @@ else: #pragma NO COVER w/o C extensions
from ._LOBTree import LOSet
from ._LOBTree import LOBTree
from ._LOBTree import LOTreeSet
from ._LOBTree import LOTreeIterator
from ._LOBTree import difference
from ._LOBTree import union
from ._LOBTree import intersection
......
......@@ -28,6 +28,7 @@ from ._base import MERGE_DEFAULT_float
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import set_operation as _set_operation
......@@ -75,6 +76,10 @@ class OITreeSetPy(TreeSet):
MERGE_DEFAULT = MERGE_DEFAULT_float
class OITreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
OIBucketPy._mapping_type = OIBucketPy._bucket_type = OIBucketPy
......@@ -103,6 +108,7 @@ except ImportError: #pragma NO COVER w/ C extensions
OISet = OISetPy
OIBTree = OIBTreePy
OITreeSet = OITreeSetPy
OITreeIterator = OITreeIteratorPy
difference = differencePy
union = unionPy
intersection = intersectionPy
......@@ -112,6 +118,7 @@ else: #pragma NO COVER w/o C extensions
from ._OIBTree import OISet
from ._OIBTree import OIBTree
from ._OIBTree import OITreeSet
from ._OIBTree import OITreeIterator
from ._OIBTree import difference
from ._OIBTree import union
from ._OIBTree import intersection
......
......@@ -28,6 +28,7 @@ from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import set_operation as _set_operation
......@@ -76,6 +77,10 @@ class OLTreeSetPy(TreeSet):
MERGE_DEFAULT = MERGE_DEFAULT_int
class OLTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
OLBucketPy._mapping_type = OLBucketPy._bucket_type = OLBucketPy
......@@ -104,6 +109,7 @@ except ImportError: #pragma NO COVER w/ C extensions
OLSet = OLSetPy
OLBTree = OLBTreePy
OLTreeSet = OLTreeSetPy
OLTreeIterator = OLTreeIteratorPy
difference = differencePy
union = unionPy
intersection = intersectionPy
......@@ -113,6 +119,7 @@ else: #pragma NO COVER w/o C extensions
from ._OLBTree import OLSet
from ._OLBTree import OLBTree
from ._OLBTree import OLTreeSet
from ._OLBTree import OLTreeIterator
from ._OLBTree import difference
from ._OLBTree import union
from ._OLBTree import intersection
......
......@@ -24,6 +24,7 @@ from ._base import Bucket
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import set_operation as _set_operation
......@@ -58,6 +59,10 @@ class OOTreeSetPy(TreeSet):
_to_key = _to_key
class OOTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
OOBucketPy._mapping_type = OOBucketPy._bucket_type = OOBucketPy
......@@ -84,6 +89,7 @@ except ImportError as e: #pragma NO COVER w/ C extensions
OOSet = OOSetPy
OOBTree = OOBTreePy
OOTreeSet = OOTreeSetPy
OOTreeIterator = OOTreeIteratorPy
difference = differencePy
union = unionPy
intersection = intersectionPy
......@@ -91,6 +97,7 @@ else: #pragma NO COVER w/o C extensions
from ._OOBTree import OOSet
from ._OOBTree import OOBTree
from ._OOBTree import OOTreeSet
from ._OOBTree import OOTreeIterator
from ._OOBTree import difference
from ._OOBTree import union
from ._OOBTree import intersection
......
......@@ -1126,6 +1126,18 @@ class _TreeItems(object):
done = 1
class _TreeIterator(object):
""" Faux implementation for BBB only.
"""
def __init__(self, items): #pragma NO COVOER
raise TypeError(
"TreeIterators are private implementation details "
"of the C-based BTrees.\n\n"
"Please use 'iter(tree)', rather than instantiating "
"one directly."
)
class Tree(_Tree):
__slots__ = ()
......
......@@ -1357,11 +1357,16 @@ class ModuleTest(object):
def _getModule(self):
pass
def testNames(self):
for name in ('Bucket', 'BTree', 'Set', 'TreeSet'):
names = ['Bucket', 'BTree', 'Set', 'TreeSet']
for name in names:
klass = getattr(self._getModule(), name)
self.assertEqual(klass.__module__, self._getModule().__name__)
self.assertTrue(klass is getattr(self._getModule(),
self.prefix + name))
# BBB for zope.app.security ZCML :(
pfx_iter = self.prefix + 'TreeIterator'
klass = getattr(self._getModule(), pfx_iter)
self.assertEqual(klass.__module__, self._getModule().__name__)
def testModuleProvides(self):
from zope.interface.verify import verifyObject
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment