From patchwork Fri May 18 14:47:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 10410987 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A7327602C2 for ; Fri, 18 May 2018 14:47:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96C6728958 for ; Fri, 18 May 2018 14:47:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B3E9289A0; Fri, 18 May 2018 14:47:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF2B828958 for ; Fri, 18 May 2018 14:47:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751914AbeEROrG (ORCPT ); Fri, 18 May 2018 10:47:06 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:60094 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751665AbeEROrF (ORCPT ); Fri, 18 May 2018 10:47:05 -0400 Received: from mail-io0-f199.google.com ([209.85.223.199]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fJgeu-0006XO-Hn for linux-wireless@vger.kernel.org; Fri, 18 May 2018 14:47:04 +0000 Received: by mail-io0-f199.google.com with SMTP id s12-v6so5279597ioc.20 for ; Fri, 18 May 2018 07:47:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=TyD+JEBWQ8nHjV4RTVbx2ShvSd6/jp2T/QOsqPYn5h0=; b=b5gXEKCfWn0PicNkP4YYn/nz3gahWcCAQnmDWB53r8HuMyGntVh9UJPOg69933MXCD ZgPA3PfM7sJFmFLGIbZ3RfN85FklcIhrN9CaV7v6aAgYZbAqzch2xufGcA38b2YeOe5F MYxV+KNeFY8WCBGoHJCYUKywRZRAEh1Kj6F4hXGkh7lxxk2MMc6pSRN29SC1Hv8r6ONn h1ytZ9J0oYHfl+fXdXpold38Oocs5808slTPu45Lw2dcUNIqVXBWCcamCd4arz0O4c6H jbiIkwUXR0be0QJrDUM9f/8pqhChC5Jq9X4GQbNpbvphH9GVmQCw741pRywUw4R9DgDI 4knA== X-Gm-Message-State: ALKqPwd0H0J1LdZ4mrxCRf6TovoZs5lSoiw1F9aexIQR69Y395xWJmDO aMHjKwXrETLRCMHYu7f2A94rohAmrGY9gOD2JtCTRjPNUYkE7HMOUkOdtiWyZRM0WhIGpr3hXXJ l/lTq+mx1tQIHHznLdZ9MAwbT8oPTFgCwRbFE8tQF7A3Y X-Received: by 2002:a6b:3fc2:: with SMTP id m185-v6mr10506038ioa.124.1526654823031; Fri, 18 May 2018 07:47:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrRlrCpMwXGhYgUzhHyRgDJ/MKb5C2yt5TSngCCxlpgVXRaB1XIRvk6+ziQVZXF8xhutoIVSg== X-Received: by 2002:a6b:3fc2:: with SMTP id m185-v6mr10506025ioa.124.1526654822794; Fri, 18 May 2018 07:47:02 -0700 (PDT) Received: from localhost ([2605:a601:ac6:7f20:508d:6240:7edf:123]) by smtp.gmail.com with ESMTPSA id k17-v6sm10758535ioo.42.2018.05.18.07.47.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 May 2018 07:47:01 -0700 (PDT) From: Seth Forshee To: wireless-regdb@lists.infradead.org Cc: linux-wireless@vger.kernel.org Subject: [PATCH] wireless-regdb: Fix comparison of WmmRule with NoneType in python 3 Date: Fri, 18 May 2018 09:47:01 -0500 Message-Id: <20180518144701.25138-1-seth.forshee@canonical.com> X-Mailer: git-send-email 2.17.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- dbparse.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/dbparse.py b/dbparse.py index 5cb8b3f13266..5fe752b4ff31 100755 --- a/dbparse.py +++ b/dbparse.py @@ -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