Commit 97577a1d authored by Jim Fulton's avatar Jim Fulton

Changed to derive from standard interfaces.

Fixed a type that prevented import.
Changed interface registration to take advantage of the fact
that we have classes.
parent e2f35e4c
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
# #
############################################################################## ##############################################################################
import OOBTree, Interface import OOBTree, Interface, Interface.Standard
class ICollection(Interface.Base): class ICollection(Interface.Base):
...@@ -97,15 +97,7 @@ class ICollection(Interface.Base): ...@@ -97,15 +97,7 @@ class ICollection(Interface.Base):
false otherwise. false otherwise.
""" """
class ISized(ICollection): class IReadSequence(Interface.Standard.Sequence):
def __len__():
"""Return the number of items in the set"""
class IReadSequence(Interface.Base):
def __getitem__(index):
"""Return an item for a given index."""
def __getslice__(index1, index2): def __getslice__(index1, index2):
"""Return a subsequence from the original sequence """Return a subsequence from the original sequence
...@@ -162,7 +154,7 @@ class ISetMutable(IKeyed): ...@@ -162,7 +154,7 @@ class ISetMutable(IKeyed):
def update(seq): def update(seq):
"""Add the items from the given sequence to the set""" """Add the items from the given sequence to the set"""
class IKeySequence(IKeyed, ISized): class IKeySequence(IKeyed, Interface.Standard.Sized):
def __getitem__(index): def __getitem__(index):
"""Return the key in the given index position """Return the key in the given index position
...@@ -178,31 +170,7 @@ class ITreeSet(IKeyed, ISetMutable): ...@@ -178,31 +170,7 @@ class ITreeSet(IKeyed, ISetMutable):
pass pass
class IDictionaryIsh(IKeyed, ISized): class IDictionaryIsh(IKeyed, Interface.Standard.MinimalDictionary):
def __getitem__(key):
"""Get the value for the given key
Raise a key error if the key if not in the collection.
"""
def get(key, default=None):
"""Get the value for the given key
Raise a key error if the key if not in the collection and no
default is specified.
Return the default if specified and 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 update(collection): def update(collection):
"""Add the items from the given collection object to the collection """Add the items from the given collection object to the collection
...@@ -273,7 +241,7 @@ class IBTree(IDictionaryIsh): ...@@ -273,7 +241,7 @@ class IBTree(IDictionaryIsh):
key=generate_key() key=generate_key()
""" """
class IMerge(Interfaces.Base): class IMerge(Interface.Base):
"""Object with methods for merging sets, buckets, and trees. """Object with methods for merging sets, buckets, and trees.
These methods are supplied in modules that define collection These methods are supplied in modules that define collection
...@@ -398,10 +366,7 @@ class IIMerge(IMerge): ...@@ -398,10 +366,7 @@ class IIMerge(IMerge):
# #
################################################################ ################################################################
OOBTree.OOSet.__implements__=ISet
Interface.assertTypeImplements(OOBTree.OOSet, ISet) OOBTree.OOTreeSet.__implements__=ITreeSet
Interface.assertTypeImplements(OOBTree.OOTreeSet, ITreeSet) OOBTree.OOBucket.__implements__=IDictionaryIsh
Interface.assertTypeImplements(OOBTree.OOBucket, IDictionaryIsh) OOBTree.OOBTree.__implements__=IBTree
Interface.assertTypeImplements(OOBTree.OOBTree, IBTree)
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