]> git.llucax.com Git - software/pymin.git/commitdiff
Add a default __cmp__() implementation to pymin.seqtool.Sequence.
authorLeandro Lucarella <llucax@gmail.com>
Tue, 16 Oct 2007 03:22:59 +0000 (00:22 -0300)
committerLeandro Lucarella <llucax@gmail.com>
Tue, 16 Oct 2007 03:22:59 +0000 (00:22 -0300)
pymin/seqtools.py
pymin/services/firewall/__init__.py
pymin/services/nat/__init__.py

index 4a6338adf28acf9d85626349f6266e0fe077ff4b..14941afc96338ae8764ff10ee769d05c9e9bc62a 100644 (file)
@@ -48,6 +48,9 @@ class Sequence:
     def __repr__(self):
         return str(self)
 
+    def __cmp__(self, other):
+        return cmp(self.as_tuple(), other.as_tuple())
+
 def as_tuple(obj):
     r"""as_tuple(obj) -> tuple :: Convert objects to tuple.
 
index c13ad010f18e2fc751e98fa0a2de80ef13d7e240..90d3ee9e44b662517db577e36ed8a4a5d76e8399 100644 (file)
@@ -61,10 +61,6 @@ class Rule(Sequence):
         if src_port is not None: self.src_port = src_port
         if dst_port is not None: self.dst_port = dst_port
 
-    def __cmp__(self, other):
-        r"Compares two Rule objects."
-        return cmp(self.as_tuple(), other.as_tuple())
-
     def as_tuple(self):
         r"Return a tuple representing the rule."
         return (self.chain, self.target, self.src, self.dst, self.protocol,
index 63fdd3288921907dce50551e39a85f0e613ba0f8..c22783ff1d4a17a2f723c38e72a05a013adfe770 100644 (file)
@@ -57,10 +57,6 @@ class PortForward(Sequence):
         if src_net is not None: self.src_net = src_net
         if dst_net is not None: self.dst_net = dst_net
 
-    def __cmp__(self, other):
-        r"Compares two PortForward objects."
-        return cmp(self.as_tuple(), other.as_tuple())
-
     def as_tuple(self):
         r"Return a tuple representing the port forward."
         return (self.dev, self.protocol, self.port, self.dst, self.dst_port,