diff options
author | Seth Forshee <seth.forshee@canonical.com> | 2018-05-18 07:39:26 -0500 |
---|---|---|
committer | Seth Forshee <seth.forshee@canonical.com> | 2018-05-18 09:46:19 -0500 |
commit | 41787549000244580b33108fb02477f3c950a01e (patch) | |
tree | 001dc637bdfb532fc8666c87fee91a1421ce4840 | |
parent | ef91a0a7517f372cecbc3d936b36497a9da7fdd7 (diff) | |
download | wireless-regdb-41787549000244580b33108fb02477f3c950a01e.tar.gz |
wireless-regdb: Fix comparison of WmmRule with NoneType in python 3
Python 3 gives errors as a result of the changes to add wmm
rules since Permission.wmmrule can be set to None:
TypeError: '<' not supported between instances of 'WmmRule' and 'NoneType'
To fix this, supply compairson methods for WmmRule instead of
using the ones provided by attrs. Doing this means we also need
to supply a __hash__ method.
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
-rwxr-xr-x | dbparse.py | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -32,7 +32,7 @@ dfs_regions = { @total_ordering -@attr.s(frozen=True) +@attr.s(frozen=True, cmp=False) class WmmRule(object): vo_c = attr.ib() vi_c = attr.ib() @@ -47,6 +47,22 @@ class WmmRule(object): return (self.vo_c, self.vi_c, self.be_c, self.bk_c, self.vo_ap, self.vi_ap, self.be_ap, self.bk_ap) + def __eq__(self, other): + if other is None: + return False + return (self._as_tuple() == other._as_tuple()) + + def __ne__(self, other): + return not (self == other) + + def __lt__(self, other): + if other is None: + return False + return (self._as_tuple() < other._as_tuple()) + + def __hash__(self): + return hash(self._as_tuple()) + class FreqBand(object): def __init__(self, start, end, bw, comments=None): self.start = start |