projects
/
invirt/packages/python-afs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Adjust for the fact that Python 2.5 doesn't have collections.MutableSet.
[invirt/packages/python-afs.git]
/
afs
/
pts.py
diff --git
a/afs/pts.py
b/afs/pts.py
index
9c44f3a
..
f99bc8f
100644
(file)
--- a/
afs/pts.py
+++ b/
afs/pts.py
@@
-1,7
+1,12
@@
import collections
from afs import _pts
import collections
from afs import _pts
-class PTRelationSet(collections.MutableSet):
+try:
+ SetMixin = collections.MutableSet
+except AttributeError:
+ SetMixin = object
+
+class PTRelationSet(SetMixin):
"""Collection class for the groups/members of a PTEntry.
This class, which acts like a set, is actually a view of the
"""Collection class for the groups/members of a PTEntry.
This class, which acts like a set, is actually a view of the
@@
-45,7
+50,8
@@
class PTRelationSet(collections.MutableSet):
Args:
elt: The element to add.
"""
Args:
elt: The element to add.
"""
- self._set.add(self._ent._pts.getEntry(elt))
+ if hasattr(self, '_set'):
+ self._set.add(self._ent._pts.getEntry(elt))
def _discard(self, elt):
"""Remove a PTEntry to this instance's internal representation.
def _discard(self, elt):
"""Remove a PTEntry to this instance's internal representation.
@@
-57,7
+63,8
@@
class PTRelationSet(collections.MutableSet):
Args:
elt: The element to discard.
"""
Args:
elt: The element to discard.
"""
- self._set.discard(self._ent._pts.getEntry(elt))
+ if hasattr(self, '_set'):
+ self._set.discard(self._ent._pts.getEntry(elt))
def __len__(self):
"""Count the members/groups in this set.
def __len__(self):
"""Count the members/groups in this set.
@@
-165,6
+172,16
@@
class PTRelationSet(collections.MutableSet):
self._discard(elt)
self._discard(elt)
+ def remove(self, elt):
+ """Remove an entity from a group; it must already be a member.
+
+ If the entity is not a member, raise a KeyError.
+ """
+ if elt not in self:
+ raise KeyError(elt)
+
+ self.discard(elt)
+
class PTEntry(object):
"""An entry in the AFS protection database.
class PTEntry(object):
"""An entry in the AFS protection database.