From: jiyin@redhat.com
To: bfields@redhat.com
Cc: linux-nfs@vger.kernel.org, "Jianhong.Yin" <yin-jianhong@163.com>
Subject: [PATCH 09/24] pynfs: python3 support plan: dict.has_key -> key in dict
Date: Tue, 24 Jul 2018 15:33:27 +0800 [thread overview]
Message-ID: <20180724073342.5738-9-jiyin@redhat.com> (raw)
In-Reply-To: <20180724073342.5738-1-jiyin@redhat.com>
From: "Jianhong.Yin" <yin-jianhong@163.com>
and rename DirList.has_key() to DirList.has_name()
to avoid confuse
Signed-off-by: Jianhong Yin <yin-jianhong@163.com>
---
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
--
2.17.1
next prev parent reply other threads:[~2018-07-24 8:39 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-24 7:33 [PATCH 01/24] pynfs: python3 support plan: print -> print() jiyin
2018-07-24 7:33 ` [PATCH 02/24] pynfs: python3 support plan: exec -> exec() jiyin
2018-07-24 7:33 ` [PATCH 03/24] pynfs: python3 support plan: "except E,e:" -> "except E as e:" jiyin
2018-07-24 7:33 ` [PATCH 04/24] pynfs: python3 support plan: "raise E, args:" -> "raise E(args)" jiyin
2018-07-24 7:33 ` [PATCH 05/24] pynfs: python3 support plan: remove suffix 'L' of long integer jiyin
2018-07-24 7:33 ` [PATCH 06/24] pynfs: python3 support plan: octal literal 0644 -> 0o644 jiyin
2018-07-24 7:33 ` [PATCH 07/24] pynfs: python3 support plan: sys.maxint -> sys.maxsize jiyin
2018-07-24 7:33 ` [PATCH 08/24] pynfs: python3 support plan: cStringIO -> StringIO jiyin
2018-07-24 7:33 ` jiyin [this message]
2018-07-24 7:33 ` [PATCH 10/24] pynfs: python3 support plan: not equal op s/ <> / != / jiyin
2018-07-24 7:33 ` [PATCH 11/24] pynfs: python3 support plan: xdrgen: remove 'L' suffix of long integer jiyin
2018-07-24 7:33 ` [PATCH 12/24] pynfs: python3 support plan: file() -> open() jiyin
2018-07-24 7:33 ` [PATCH 13/24] pynfs: python3 support plan: list.sort() -> newlist = sorted(list) jiyin
2018-07-24 7:33 ` [PATCH 14/24] pynfs: python3 support plan: Relative Import -> Absolute Import jiyin
2018-07-24 7:33 ` [PATCH 15/24] pynfs: python3 support plan: fix 'socket' has no attribute '_socketobject' jiyin
2018-07-24 7:33 ` [PATCH 16/24] pynfs: python3 support plan: remove cPickle jiyin
2018-07-24 7:33 ` [PATCH 17/24] pynfs: python3 support plan: fix indent error on python3 jiyin
2018-07-24 7:33 ` [PATCH 18/24] pynfs: python3 support plan: fix 'TypeError: must be str, not bytes' jiyin
2018-07-24 7:33 ` [PATCH 19/24] pynfs: python3 support plan: fix import fail on python3 jiyin
2018-07-24 7:33 ` [PATCH 20/24] pynfs: python3 support plan: fix 'dict' has no attribute 'iteritems' jiyin
2018-07-24 7:33 ` [PATCH 21/24] pynfs: python3 support plan: fix sort() fail and require python version jiyin
2018-07-24 7:33 ` [PATCH 22/24] pynfs: python3 support plan: fix ord() failure on python3 jiyin
2018-07-24 7:33 ` [PATCH 23/24] pynfs: python3 support plan: fix except multi exceptions in one line jiyin
2018-07-24 7:33 ` [PATCH 24/24] pynfs: python3 support plan: fix access class var in list comprehension jiyin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180724073342.5738-9-jiyin@redhat.com \
--to=jiyin@redhat.com \
--cc=bfields@redhat.com \
--cc=linux-nfs@vger.kernel.org \
--cc=yin-jianhong@163.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).