Source

intspan / intspan.py

Diff from to

intspan.py

 
-import sys
+import sys, copy
 from itertools import groupby, count
 
-
 _PY3 = sys.version_info[0] > 2
 if _PY3:
     basestring = str
         
 class intspan(set):
     def __init__(self, initial=None):
-        set.__init__(self)
+        super(intspan, self).__init__()
         if initial:
             self.update(initial)
+            
+    def copy(self):
+        return copy.copy(self)
         
     def update(self, items):
-        set.update(self, self._parse_range(items))
+        super(intspan, self).update(self._parse_range(items))
         
     def discard(self, items):
         for item in self._parse_range(items):
-            set.discard(self, item)
+            super(intspan, self).discard(item)
             
     def remove(self, items):
         for item in self._parse_range(items):
-            set.remove(self, item)
+            super(intspan, self).remove(item)
             
     def add(self, items):
         for item in self._parse_range(items):
-            set.add(self, item)
-                
+            super(intspan, self).add(item)
+    
+    def issubset(self, items):
+        return super(intspan, self).issubset(self._parse_range(items))
+    
+    def issuperset(self, items):
+        return super(intspan, self).issuperset(self._parse_range(items))
+    
+    def union(self, items):
+        return intspan(super(intspan, self).union(self._parse_range(items)))
+
+    def intersection(self, items):
+        return intspan(super(intspan, self).intersection(self._parse_range(items)))
+    
+    def difference(self, items):
+        return intspan(super(intspan, self).difference(self._parse_range(items)))
+    
+    def symmetric_difference(self, items):
+        return intspan(super(intspan, self).symmetric_difference(self._parse_range(items)))
+
+    __le__  = issubset
+    __ge__  = issuperset 
+    __or__  = union
+    __and__ = intersection
+    __sub__ = difference
+    __xor__ = symmetric_difference
+    
+    def __ior__(self, items):
+        return super(intspan, self).__ior__(self._parse_range(items))
+        
+    def __iand__(self, items):
+        return super(intspan, self).__iand__(self._parse_range(items))
+
+    def __isub__(self, items):
+        return super(intspan, self).__isub__(self._parse_range(items))
+        
+    def __ixor__(self, items):
+        return super(intspan, self).__ixor__(self._parse_range(items))
+    
+    def __eq__(self, items):
+        return super(intspan, self).__eq__(self._parse_range(items))
+        
     def __iter__(self):
         """
         Iterate in ascending order.
         """
-        return iter(sorted(set.__iter__(self)))
+        return iter(sorted(super(intspan, self).__iter__()))
     
     @staticmethod
     def _parse_range(datum):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.