]> git.pld-linux.org Git - projects/pld-ftp-admin.git/commitdiff
Use 'x in dict' syntax, it's more pythonic and has_key() is gone in python3
authorJan Rękorajski <baggins@pld-linux.org>
Sun, 17 Jan 2021 10:25:30 +0000 (11:25 +0100)
committerJan Rękorajski <baggins@pld-linux.org>
Sun, 17 Jan 2021 10:25:30 +0000 (11:25 +0100)
bin/pfa-from-incoming
modules/baseftptree.py
modules/ftptree.py

index 1696bf63c934d4e762882865d18c1495543cd2ae..0023261feb1d4979d5c99b3015254852f7c18fbc 100755 (executable)
@@ -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
 
index 1f3febc0e7c7dca046362ee732fb331e1dfcbc8c..af47c7649f5d6a6b2071807c042c5d486752436d 100644 (file)
@@ -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])
 
index e5b33c62347fb0fcb680de0f5df2fc0098681cc3..3b1af3ce69d38b5ff2c066d505c656c2787df2b1 100644 (file)
@@ -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):
This page took 0.127773 seconds and 4 git commands to generate.