From patchwork Tue Jul 24 07:33:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianhong Yin X-Patchwork-Id: 10541409 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2DDA17FD for ; Tue, 24 Jul 2018 07:34:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A82D628759 for ; Tue, 24 Jul 2018 07:34:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CAE32875E; Tue, 24 Jul 2018 07:34:10 +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 29E1328759 for ; Tue, 24 Jul 2018 07:34:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388390AbeGXIjP (ORCPT ); Tue, 24 Jul 2018 04:39:15 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54820 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388391AbeGXIjP (ORCPT ); Tue, 24 Jul 2018 04:39:15 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D1A137DAC2; Tue, 24 Jul 2018 07:34:07 +0000 (UTC) Received: from dhcp-12-115.nay.redhat.com (unknown [10.66.12.115]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4592C178B4; Tue, 24 Jul 2018 07:34:05 +0000 (UTC) From: jiyin@redhat.com To: bfields@redhat.com Cc: linux-nfs@vger.kernel.org, "Jianhong.Yin" Subject: [PATCH 09/24] pynfs: python3 support plan: dict.has_key -> key in dict Date: Tue, 24 Jul 2018 15:33:27 +0800 Message-Id: <20180724073342.5738-9-jiyin@redhat.com> In-Reply-To: <20180724073342.5738-1-jiyin@redhat.com> References: <20180724073342.5738-1-jiyin@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 24 Jul 2018 07:34:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 24 Jul 2018 07:34:07 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jiyin@redhat.com' RCPT:'' Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Jianhong.Yin" and rename DirList.has_key() to DirList.has_name() to avoid confuse Signed-off-by: Jianhong Yin --- nfs4.0/lib/rpc/rpc.py | 2 +- nfs4.0/nfs4lib.py | 2 +- nfs4.0/nfs4server.py | 4 ++-- nfs4.0/nfs4state.py | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/nfs4.0/lib/rpc/rpc.py b/nfs4.0/lib/rpc/rpc.py index d9c1401..be14658 100644 --- a/nfs4.0/lib/rpc/rpc.py +++ b/nfs4.0/lib/rpc/rpc.py @@ -514,7 +514,7 @@ class RPCServer(Server): 'sys': AUTH_SYS, 'gss': RPCSEC_GSS, }.iteritems(): - if supported.has_key(secname): + if secname in supported: self.security[sectype] = supported[secname]() self.readbufs = {} diff --git a/nfs4.0/nfs4lib.py b/nfs4.0/nfs4lib.py index 5c9e853..dddbf91 100644 --- a/nfs4.0/nfs4lib.py +++ b/nfs4.0/nfs4lib.py @@ -232,7 +232,7 @@ class CBServer(rpc.RPCServer): results = [] ok = NFS4_OK for op in cmp4args.argarray: - if self.opcodes.has_key(op.argop): + if op.argop in self.opcodes: ok, result = self.opcodes[op.argop](op, cbid) else: ok = NFS4ERR_OP_ILLEGAL diff --git a/nfs4.0/nfs4server.py b/nfs4.0/nfs4server.py index 163bd60..18b0aad 100755 --- a/nfs4.0/nfs4server.py +++ b/nfs4.0/nfs4server.py @@ -504,7 +504,7 @@ class NFS4Server(rpc.RPCServer): if op.opopen.openhow.how.mode == GUARDED4: raise NFS4Error(NFS4ERR_EXIST) # with an existing file ignore attrs except size=0 - if attrs.has_key(FATTR4_SIZE) and attrs[FATTR4_SIZE]==0: + if FATTR4_SIZE in attrs and attrs[FATTR4_SIZE]==0: attrset = existing.set_attributes(attrdict={FATTR4_SIZE:0}) # Now break out and use existing as is else: @@ -593,7 +593,7 @@ class NFS4Server(rpc.RPCServer): def op_putfh(self, op): print(" FILEHANDLE '%s'" % repr(op.opputfh.object)) # check access! - if not self.fhcache.has_key(op.opputfh.object): + if not op.opputfh.object in self.fhcache: return simple_error(NFS4ERR_BADHANDLE) self.curr_fh = self.fhcache[op.opputfh.object] return simple_error(NFS4_OK) diff --git a/nfs4.0/nfs4state.py b/nfs4.0/nfs4state.py index cd36edd..8aca178 100755 --- a/nfs4.0/nfs4state.py +++ b/nfs4.0/nfs4state.py @@ -1014,7 +1014,7 @@ class VirtualHandle(NFSFileHandle): # Must make sure that if it fails, nothing is changed if self.fattr4_type != NF4DIR: raise "create called on non-directory (%s)" % self.ref - if self.dirent.has_key(name): + if self.dirent.has_name(name): raise "attempted to create already existing file." fh = VirtualHandle(name, type, self) if FATTR4_SIZE in attrs and type.type != NF4REG: @@ -1116,7 +1116,7 @@ class VirtualHandle(NFSFileHandle): mapping = nfs4lib.list2bitmap ret_list = [] for attr in attrdict.keys(): - if not self.supported.has_key(attr): + if not attr in self.supported: raise NFS4Error(NFS4ERR_ATTRNOTSUPP, attrs=mapping(ret_list)) if 'w' not in self.supported[attr]: raise NFS4Error(NFS4ERR_INVAL, attrs=mapping(ret_list)) @@ -1182,7 +1182,7 @@ class VirtualHandle(NFSFileHandle): # Make sure any error is recorded in fattr4_rdattr_error ret_dict = {} for attr in attrlist: - if not self.supported.has_key(attr): + if not attr in self.supported: # Ignore unknown attributes continue if 'r' not in self.supported[attr]: @@ -1419,7 +1419,7 @@ class HardHandle(NFSFileHandle): self.oldfiles = self.dirent.keys() for i in os.listdir(self.file): fullfile = os.path.join(self.file, i) - if not self.dirent.has_key(i): + if not self.dirent.has_name(i): self.dirent[i] = HardHandle(i, self, fullfile) else: self.oldfiles.remove(i) @@ -1520,7 +1520,7 @@ class DirList: else: return self.list[i:] - def has_key(self, name): + def has_name(self, name): for x in self.list: if x.name == name: return True