[Zope-Checkins] CVS: Zope/lib/python/BTrees - __init__.py:1.3.84.5 Interfaces.py:1.7.18.6 IOBTree.py:1.3.18.3 IIBTree.py:1.3.18.3
Jeremy Hylton
jeremy@zope.com
Tue, 24 Sep 2002 16:26:51 -0400
Update of /cvs-repository/Zope/lib/python/BTrees
In directory cvs.zope.org:/tmp/cvs-serv1956
Modified Files:
Tag: Zope-2_5-branch
__init__.py Interfaces.py IOBTree.py IIBTree.py
Log Message:
Backout changes made to these files since the 2.5 branch was created.
The versions of these files that existed when the branch was created
are correct. The BTrees and PluginIndexes pass with these versions of
these files. The backport of 2.6 changes to the branch included a
bunch of code that didn't work on 2.5, and subsequent attempts to
repair have only made things worse.
There are some minor mysteries in this code: Why does it import intSet
and delete it immediately? What side-effect does that import have?
Why do we message with the __module__ attribute of all the objects in
OOBTrees, etc. BUT these mysteries exist for the trunk and the
original 2.5 release. It will only make matters worse to change them
only on this branch and without any idea what the code is trying to
do.
=== Zope/lib/python/BTrees/__init__.py 1.3.84.4 => 1.3.84.5 ===
--- Zope/lib/python/BTrees/__init__.py:1.3.84.4 Tue Sep 24 15:41:54 2002
+++ Zope/lib/python/BTrees/__init__.py Tue Sep 24 16:26:50 2002
@@ -1 +1,13 @@
-# Empty init file
+import ZODB
+
+try: import intSet
+except: pass
+else: del intSet
+
+# Register interfaces
+try: import Interface
+except ImportError: pass # Don't register interfaces if no scarecrow
+else:
+ import Interfaces
+ del Interfaces
+ del Interface
=== Zope/lib/python/BTrees/Interfaces.py 1.7.18.5 => 1.7.18.6 ===
--- Zope/lib/python/BTrees/Interfaces.py:1.7.18.5 Tue Sep 10 17:48:24 2002
+++ Zope/lib/python/BTrees/Interfaces.py Tue Sep 24 16:26:50 2002
@@ -12,10 +12,9 @@
#
##############################################################################
-import OOBTree, Interface
-from Interface import Interface
+import OOBTree, Interface, Interface.Standard
-class ICollection(Interface):
+class ICollection(Interface.Base):
def clear():
"""Remove all of the items from the collection"""
@@ -27,14 +26,7 @@
false otherwise.
"""
-
-class IReadSequence(Interface):
-
- def __getitem__(index):
- """Return a value at the givem index
-
- An IndexError is raised if the index cannot be found.
- """
+class IReadSequence(Interface.Standard.Sequence):
def __getslice__(index1, index2):
"""Return a subsequence from the original sequence
@@ -78,7 +70,7 @@
"""
class ISetMutable(IKeyed):
-
+
def insert(key):
"""Add the key (value) to the set.
@@ -87,17 +79,11 @@
def remove(key):
"""Remove the key from the set."""
-
+
def update(seq):
"""Add the items from the given sequence to the set"""
-class ISized(Interface):
- "anything supporting __len"
-
- def __len__():
- """Return the number of items in the container"""
-
-class IKeySequence(IKeyed, ISized):
+class IKeySequence(IKeyed, Interface.Standard.Sized):
def __getitem__(index):
"""Return the key in the given index position
@@ -111,52 +97,9 @@
class ITreeSet(IKeyed, ISetMutable):
pass
+
-class IMinimalDictionary(ISized):
-
- def has_key(key):
- """Check whether the object has an item with the given key"""
-
-
- def get(key, default):
- """Get the value for the given key
-
- Return the default if the key is not in the collection.
- """
-
- def __setitem__(key, value):
- """Set the value for the given key"""
-
- def __delitem__(key):
- """delete the value for the given key
-
- Raise a key error if the key if not in the collection."""
-
- def values():
- """Return a IReadSequence containing the values in the collection
-
- The type of the IReadSequence is not specified. It could be a
- list or a tuple or some other type.
- """
-
- def keys():
- """Return an Sequence containing the keys in the collection
-
- The type of the IReadSequence is not specified. It could be a
- list or a tuple or some other type.
- """
-
- def items():
- """Return a IReadSequence containing the items in the collection
-
- An item is a key-value tuple.
-
- The type of the IReadSequence is not specified. It could be a
- list or a tuple or some other type.
- """
-
-
-class IDictionaryIsh(IKeyed, IMinimalDictionary):
+class IDictionaryIsh(IKeyed, Interface.Standard.MinimalDictionary):
def update(collection):
"""Add the items from the given collection object to the collection
@@ -205,7 +148,7 @@
the minimum value. This normalization may be a noop, but, for
integer values, the normalization is division.
"""
-
+
class IBTree(IDictionaryIsh):
def insert(key, value):
@@ -227,7 +170,7 @@
key=generate_key()
"""
-class IMerge(Interface):
+class IMerge(Interface.Base):
"""Object with methods for merging sets, buckets, and trees.
These methods are supplied in modules that define collection
@@ -249,11 +192,8 @@
"""Return the keys or items in c1 for which there is no key in
c2.
- If c1 is None, then None is returned. If c2 is None, then c1
+ If c1 is None, then None is returned. If c2 is none, then c1
is returned.
-
- If neither c1 nor c2 is None, the output is a Set if c1 is a Set or
- TreeSet, and is a Bucket if c1 is a Bucket or BTree.
"""
def union(c1, c2):
@@ -286,66 +226,61 @@
"""
def weightedUnion(c1, c2, weight1=1, weight2=1):
- """Compute the weighted union of c1 and c2.
+ """Compute the weighted Union of c1 and c2.
- If c1 and c2 are None, the output is (0, None).
+ If c1 and c2 are None, the output is 0 and None
- If c1 is None and c2 is not None, the output is (weight2, c2).
-
- If c1 is not None and c2 is None, the output is (weight1, c1).
-
- Else, and hereafter, c1 is not None and c2 is not None.
+ if c1 is None and c2 is not None, the output is weight2 and
+ c2.
- If c1 and c2 are both sets, the output is 1 and the (unweighted)
- union of the sets.
+ if c1 is not None and c2 not None and both sets, the output is
+ weight1 and c1.
- Else the output is 1 and a Bucket whose keys are the union of c1 and
- c2's keys, and whose values are::
+ If c1 and c2 are not None and not both sets, the output is 1
+ and a Bucket such that the output values are::
v1*weight1 + v2*weight2
where:
- v1 is 0 if the key is not in c1
- 1 if the key is in c1 and c1 is a set
- c1[key] if the key is in c1 and c1 is a mapping
-
- v2 is 0 if the key is not in c2
- 1 if the key is in c2 and c2 is a set
- c2[key] if the key is in c2 and c2 is a mapping
+ v1 is 0 if the key was not in c1. Otherwise, v1 is 1, if
+ c1 is a set, or the value from c1.
- Note that c1 and c2 must be collections.
+ v2 is 0 if the key was not in c2. Otherwise, v2 is 2, if
+ c2 is a set, or the value from c2.
+
+ Note that c1 and c2 must be collections.
"""
def weightedIntersection(c1, c2, weight1=1, weight2=1):
"""Compute the weighted intersection of c1 and c2.
- If c1 and c2 are None, the output is (0, None).
-
- If c1 is None and c2 is not None, the output is (weight2, c2).
+ If c1 and c2 are None, the output is None, None.
- If c1 is not None and c2 is None, the output is (weight1, c1).
+ if c1 is None and c2 is not None, the output is weight2 and
+ c2.
- Else, and hereafter, c1 is not None and c2 is not None.
+ if c1 is not None and c2 not None, the output is weight1 and
+ c1.
If c1 and c2 are both sets, the output is the sum of the weights
and the (unweighted) intersection of the sets.
- Else the output is 1 and a Bucket whose keys are the intersection of
- c1 and c2's keys, and whose values are::
+ If c1 and c2 are not None and not both sets, the output is 1
+ and a Bucket such that the output values are::
v1*weight1 + v2*weight2
where:
- v1 is 1 if c1 is a set
- c1[key] if c1 is a mapping
+ v1 is 0 if the key was not in c1. Otherwise, v1 is 1, if
+ c1 is a set, or the value from c1.
- v2 is 1 if c2 is a set
- c2[key] if c2 is a mapping
+ v2 is 0 if the key was not in c2. Otherwise, v2 is 2, if
+ c2 is a set, or the value from c2.
- Note that c1 and c2 must be collections.
+ Note that c1 and c2 must be collections.
"""
###############################################################
=== Zope/lib/python/BTrees/IOBTree.py 1.3.18.2 => 1.3.18.3 ===
--- Zope/lib/python/BTrees/IOBTree.py:1.3.18.2 Tue Sep 10 17:48:24 2002
+++ Zope/lib/python/BTrees/IOBTree.py Tue Sep 24 16:26:50 2002
@@ -17,6 +17,6 @@
# We don't really want _ names in pickles, so update all of the __module__
# references.
-##for o in globals().values():
-## if hasattr(o, '__module__'):
-## o.__module__=__name__
+for o in globals().values():
+ if hasattr(o, '__module__'):
+ o.__module__=__name__
=== Zope/lib/python/BTrees/IIBTree.py 1.3.18.2 => 1.3.18.3 ===
--- Zope/lib/python/BTrees/IIBTree.py:1.3.18.2 Tue Sep 10 17:48:24 2002
+++ Zope/lib/python/BTrees/IIBTree.py Tue Sep 24 16:26:50 2002
@@ -17,6 +17,6 @@
# We don't really want _ names in pickles, so update all of the __module__
# references.
-##for o in globals().values():
-## if hasattr(o, '__module__'):
-## o.__module__=__name__
+for o in globals().values():
+ if hasattr(o, '__module__'):
+ o.__module__=__name__