[projects/pld-ftp-admin] Fix list and iterators assumptions that are no longer valid in python3

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


commit f09b8024554f99d92337f94693bf65442301d097
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Sun Jan 17 11:42:16 2021 +0100

    Fix list and iterators assumptions that are no longer valid in python3

 bin/pfa-signpkg    |  2 +-
 modules/cmds.py    |  7 +++----
 modules/ftptree.py | 10 +++++-----
 3 files changed, 9 insertions(+), 10 deletions(-)
---
diff --git a/bin/pfa-signpkg b/bin/pfa-signpkg
index 044ffe3..0bd8e6e 100755
--- a/bin/pfa-signpkg
+++ b/bin/pfa-signpkg
@@ -102,7 +102,7 @@ def chunk(seq, size, pad=None):
      '''
      n = len(seq)
      mod = n % size
-     for i in xrange(0, n - mod, size):
+     for i in range(0, n - mod, size):
          yield seq[i : i + size]
      if mod:
          yield seq[-mod:]
diff --git a/modules/cmds.py b/modules/cmds.py
index 80a0ecb..9fa2b19 100644
--- a/modules/cmds.py
+++ b/modules/cmds.py
@@ -88,7 +88,7 @@ def load_creds():
         return
     else:
         f=open(common.ftpadmdir+'/var/passwd', 'r')
-        for line in f.xreadlines():
+        for line in f:
             x=line.strip().split(':')
             if len(x)>=2:
                 users[x[0]]=x[1]
@@ -97,7 +97,7 @@ def load_creds():
         return
     else:
         f=open(common.ftpadmdir+'/var/cookies', 'r')
-        for line in f.xreadlines():
+        for line in f:
             x=line.strip().split(':')
             if len(x)>=2:
                 users[x[0]]=x[1]
@@ -147,8 +147,7 @@ def cmd_logout(con):
 def reloadftptree():
     global srctree, pkglist
     srctree=ftptree.FtpTree(config.value['default_to'], loadall=True)
-    pkglist=srctree.keys()
-    pkglist.sort()
+    pkglist=sorted(srctree.keys())
 
 def cmd_gettree(con):
     buf=''
diff --git a/modules/ftptree.py b/modules/ftptree.py
index c45c131..2c09a69 100644
--- a/modules/ftptree.py
+++ b/modules/ftptree.py
@@ -382,8 +382,8 @@ class FtpTree(BaseFtpTree):
                 return True
             else:
                 return False
-        list = filter(checkfiletype, os.listdir(self.basedir+'/SRPMS/.metadata'))
-        self.pkgnames = map((lambda x: x[:-13]), list)
+        pkglist = list(filter(checkfiletype, os.listdir(self.basedir+'/SRPMS/.metadata')))
+        self.pkgnames = list(map((lambda x: x[:-13]), pkglist))
 
     def __mark4something(self, wannabepkgs, markfunction):
         def chopoffextension(pkg):
@@ -500,7 +500,7 @@ class FtpTree(BaseFtpTree):
                 return True
             else:
                 return False
-        return filter(filter_other_pkgs, tree.pkgnames)
+        return list(filter(filter_other_pkgs, tree.pkgnames))
 
     def __find_older_pkgs(self, pkg):
         def filter_older_pkgs(x):
@@ -511,7 +511,7 @@ class FtpTree(BaseFtpTree):
                 return True
             else:
                 return False
-        return filter(filter_older_pkgs, self.__find_other_pkgs(pkg, self))
+        return list(filter(filter_older_pkgs, self.__find_other_pkgs(pkg, self)))
 
     def __checksigns(self, tree, pkgs, test = False):
         """
@@ -548,7 +548,7 @@ class FtpTree(BaseFtpTree):
         def findbyname(name):
             def x(nvr):
                 return '-'.join(nvr.split('-')[:-2]) == name
-            return filter(x, tree.pkgnames)
+            return list(filter(x, tree.pkgnames))
 
         for pkg in pkgs:
             obsoletes = pkg.obsoletes()
================================================================

---- gitweb:

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



More information about the pld-cvs-commit mailing list