]> git.pld-linux.org Git - projects/pld-ftp-admin.git/blobdiff - bin/pfa-from-incoming
Use 'x in dict' syntax, it's more pythonic and has_key() is gone in python3
[projects/pld-ftp-admin.git] / bin / pfa-from-incoming
index 92b75d1c740037b37bd53588d8d603e550df7e0f..0023261feb1d4979d5c99b3015254852f7c18fbc 100755 (executable)
@@ -13,7 +13,7 @@ from baseftptree import BaseFtpTree, BasePkg
 from ftptree import FtpTree, Pkg
 import ftpio
 
-os.umask(022)
+os.umask(0o022)
 
 def rm(file):
     os.remove(file)
@@ -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):
@@ -239,7 +239,7 @@ for arch in ftp_archs:
                     dstfile = default_to + arch + '/RPMS'
                 try:
                     rm(dstfile + '/' + rpmfile)
-                except OSError, e:
+                except OSError as e:
                     l = "Removing %s problem: %s" % (dstfile + '/' + rpmfile, e)
                     ftpio.log(l)
                     print(l)
@@ -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
 
@@ -267,7 +267,7 @@ for arch in ftp_archs:
 
                 try:
                     mv(srcfile, dstfile)
-                except OSError, e:
+                except OSError as e:
                     l = "Moving %s to %s problem: %s" % (srcfile, dstfile, e)
                     ftpio.log(l)
                     print(l)
This page took 0.027765 seconds and 4 git commands to generate.