[projects/pld-ftp-admin] Use 'x in dict' syntax, it's more pythonic and has_key() is gone in python3

baggins baggins at pld-linux.org
Sun Jan 17 11:46:22 CET 2021


commit b353ff36947c3bd21ad86a7dbbaa9cbe2c1616a8
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Sun Jan 17 11:25:30 2021 +0100

    Use 'x in dict' syntax, it's more pythonic and has_key() is gone in python3

 bin/pfa-from-incoming  | 8 ++++----
 modules/baseftptree.py | 4 ++--
 modules/ftptree.py     | 6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/bin/pfa-from-incoming b/bin/pfa-from-incoming
index 1696bf6..0023261 100755
--- a/bin/pfa-from-incoming
+++ b/bin/pfa-from-incoming
@@ -97,7 +97,7 @@ Subject: %s
     sm.close()
 
 def move_noarch(f, arch, rpmfile, dstpkg):
-    if dstpkg.noarch_arch.has_key(rpmfile):
+    if rpmfile in dstpkg.noarch_arch:
         os.system("LC_ALL=C rpm -qlp %s | LC_ALL=C sort > %s/files.new" %
                   (incoming_dir + arch + '/' + rpmfile, tmpdir))
         os.system("rpm -qRp %s | LC_ALL=C sort | LC_ALL=C uniq > %s/reqs.new" %
@@ -122,7 +122,7 @@ def move_noarch(f, arch, rpmfile, dstpkg):
                   (incoming_dir + arch + '/' + rpmfile, noarchcachedir, rpmfile))
         os.system("rpm -qRp %s | LC_ALL=C sort | LC_ALL=C uniq > %s/%s.reqlist" %
                   (incoming_dir + arch + '/' + rpmfile, noarchcachedir, rpmfile))
-        if not dstpkg.files.has_key(arch):
+        if arch not in dstpkg.files:
             f.write("file:noarch:%s\ninfo:noarch_arch:%s:%s\n" % (rpmfile, rpmfile, arch))
         mv(incoming_dir + arch + '/' + rpmfile, default_to + 'noarch/RPMS')
 
@@ -230,7 +230,7 @@ for arch in ftp_archs:
 
         dstpkg = BasePkg(`srcpkg`, ftptree)
 
-        if dstpkg.files.has_key(arch):
+        if arch in dstpkg.files:
             ftpio.log("files from %s for arch %s already present in %s; removing older files" % (`srcpkg`, arch, ftptree))
             for rpmfile in dstpkg.files[arch]:
                 if is_debuginfo(rpmfile):
@@ -256,7 +256,7 @@ for arch in ftp_archs:
             if rpmfile[-11:] == '.noarch.rpm' and config.separate_noarch:
                 move_noarch(f, arch, rpmfile, dstpkg)
             else:
-                if not dstpkg.files.has_key(arch):
+                if arch not in dstpkg.files:
                     f.write("file:%s:%s\n" % (arch, rpmfile))
                 srcfile = incoming_dir + arch + '/' + rpmfile
 
diff --git a/modules/baseftptree.py b/modules/baseftptree.py
index 1f3febc..af47c76 100644
--- a/modules/baseftptree.py
+++ b/modules/baseftptree.py
@@ -36,7 +36,7 @@ class BasePkg:
                 if len(i)==3:
                     self.info[i[1]]=i[2]
                 elif i[1]=='build':
-                    if not self.build.has_key(i[2]):
+                    if i[2] not in self.build:
                         self.build[i[2]]=Build()
                         self.lastbid=i[2]
                     if i[3]=='requester':
@@ -48,7 +48,7 @@ class BasePkg:
                 else:
                     self.info[i[1]]=i[2:]
             elif i[0] == 'file':
-                if not self.files.has_key(i[1]):
+                if i[1] not in self.files:
                     self.files[i[1]]=[]
                 self.files[i[1]].append(i[2])
 
diff --git a/modules/ftptree.py b/modules/ftptree.py
index e5b33c6..3b1af3c 100644
--- a/modules/ftptree.py
+++ b/modules/ftptree.py
@@ -141,7 +141,7 @@ class Pkg(BasePkg):
 
     def load(self, content=None):
         BasePkg.load(self, content)
-        if self.info.has_key('move'):
+        if 'move' in self.info:
             self.mark4moving()
 
     def writeinfo(self):
@@ -275,7 +275,7 @@ class FtpTree(BaseFtpTree):
         self.do_checkbuild = True
 
     def __getitem__(self, key):
-        if self.loadedpkgs.has_key(key):
+        if key in self.loadedpkgs:
             return self.loadedpkgs[key]
         elif key in self.pkgnames:
             pkg=Pkg(key, self)
@@ -414,7 +414,7 @@ class FtpTree(BaseFtpTree):
 
         for pkg in marked:
             for bid in pkg.build.keys():
-                if requests.has_key(bid) and not requests[bid].find('?') == -1:
+                if bid in requests and not requests[bid].find('?') == -1:
                     pkg.error("(buildid %s) building not finished" % bid)
 
     def __checkarchs(self, dsttree, marked):
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-ftp-admin.git/commitdiff/7aec4c36547d10c790a119a1ac203eee13755a6d



More information about the pld-cvs-commit mailing list