comparison env/lib/python3.7/site-packages/lxml/html/_setmixin.py @ 5:9b1c78e6ba9c draft default tip

"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
author shellac
date Mon, 01 Jun 2020 08:59:25 -0400
parents 79f47841a781
children
comparison
equal deleted inserted replaced
4:79f47841a781 5:9b1c78e6ba9c
1 try:
2 from collections.abc import MutableSet
3 except ImportError:
4 from collections import MutableSet
5
6
7 class SetMixin(MutableSet):
8
9 """
10 Mix-in for sets. You must define __iter__, add, remove
11 """
12
13 def __len__(self):
14 length = 0
15 for item in self:
16 length += 1
17 return length
18
19 def __contains__(self, item):
20 for has_item in self:
21 if item == has_item:
22 return True
23 return False
24
25 issubset = MutableSet.__le__
26 issuperset = MutableSet.__ge__
27
28 union = MutableSet.__or__
29 intersection = MutableSet.__and__
30 difference = MutableSet.__sub__
31 symmetric_difference = MutableSet.__xor__
32
33 def copy(self):
34 return set(self)
35
36 def update(self, other):
37 self |= other
38
39 def intersection_update(self, other):
40 self &= other
41
42 def difference_update(self, other):
43 self -= other
44
45 def symmetric_difference_update(self, other):
46 self ^= other
47
48 def discard(self, item):
49 try:
50 self.remove(item)
51 except KeyError:
52 pass
53
54 @classmethod
55 def _from_iterable(cls, it):
56 return set(it)