Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OOBTree.py 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. ##############################################################################
  2. #
  3. # Copyright (c) 2001-2012 Zope Foundation and Contributors.
  4. # All Rights Reserved.
  5. #
  6. # This software is subject to the provisions of the Zope Public License,
  7. # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
  8. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
  9. # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10. # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
  11. # FOR A PARTICULAR PURPOSE
  12. #
  13. ##############################################################################
  14. __all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
  15. 'OOBucket', 'OOSet', 'OOBTree', 'OOTreeSet',
  16. 'union', 'intersection','difference',
  17. )
  18. from zope.interface import moduleProvides
  19. from .Interfaces import IObjectObjectBTreeModule
  20. from ._base import Bucket
  21. from ._base import Set
  22. from ._base import Tree as BTree
  23. from ._base import TreeSet
  24. from ._base import _TreeIterator
  25. from ._base import difference as _difference
  26. from ._base import intersection as _intersection
  27. from ._base import set_operation as _set_operation
  28. from ._base import to_ob as _to_key
  29. _to_value = _to_key
  30. from ._base import union as _union
  31. from ._base import _fix_pickle
  32. from ._compat import import_c_extension
  33. _BUCKET_SIZE = 30
  34. _TREE_SIZE = 250
  35. using64bits = False
  36. class OOBucketPy(Bucket):
  37. _to_key = _to_key
  38. _to_value = _to_value
  39. class OOSetPy(Set):
  40. _to_key = _to_key
  41. class OOBTreePy(BTree):
  42. max_leaf_size = _BUCKET_SIZE
  43. max_internal_size = _TREE_SIZE
  44. _to_key = _to_key
  45. _to_value = _to_value
  46. class OOTreeSetPy(TreeSet):
  47. max_leaf_size = _BUCKET_SIZE
  48. max_internal_size = _TREE_SIZE
  49. _to_key = _to_key
  50. class OOTreeIteratorPy(_TreeIterator):
  51. pass
  52. # Can't declare forward refs, so fix up afterwards:
  53. OOBucketPy._mapping_type = OOBucketPy._bucket_type = OOBucketPy
  54. OOBucketPy._set_type = OOSetPy
  55. OOSetPy._mapping_type = OOBucketPy
  56. OOSetPy._set_type = OOSetPy._bucket_type = OOSetPy
  57. OOBTreePy._mapping_type = OOBTreePy._bucket_type = OOBucketPy
  58. OOBTreePy._set_type = OOSetPy
  59. OOTreeSetPy._mapping_type = OOBucketPy
  60. OOTreeSetPy._set_type = OOTreeSetPy._bucket_type = OOSetPy
  61. differencePy = _set_operation(_difference, OOSetPy)
  62. unionPy = _set_operation(_union, OOSetPy)
  63. intersectionPy = _set_operation(_intersection, OOSetPy)
  64. import_c_extension(globals())
  65. _fix_pickle(globals(), __name__)
  66. moduleProvides(IObjectObjectBTreeModule)