From: Leandro Lucarella Date: Tue, 16 Oct 2007 03:22:59 +0000 (-0300) Subject: Add a default __cmp__() implementation to pymin.seqtool.Sequence. X-Git-Url: https://git.llucax.com/software/pymin.git/commitdiff_plain/865ddb235489f38afd7043ee269e4f958474bd5a?ds=inline Add a default __cmp__() implementation to pymin.seqtool.Sequence. --- diff --git a/pymin/seqtools.py b/pymin/seqtools.py index 4a6338a..14941af 100644 --- a/pymin/seqtools.py +++ b/pymin/seqtools.py @@ -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. diff --git a/pymin/services/firewall/__init__.py b/pymin/services/firewall/__init__.py index c13ad01..90d3ee9 100644 --- a/pymin/services/firewall/__init__.py +++ b/pymin/services/firewall/__init__.py @@ -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, diff --git a/pymin/services/nat/__init__.py b/pymin/services/nat/__init__.py index 63fdd32..c22783f 100644 --- a/pymin/services/nat/__init__.py +++ b/pymin/services/nat/__init__.py @@ -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,