[PATCH] Rewrote parts of pkgorder script to improve it's speed. (#451083)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Function printMatchingPkgs() was making glob.glob calls everytime it was used.
Rewrote parts of the script to build the list of the packages just once,
and then use fnmatch() to print the matching packages.
Also some unnecessary import calls were removed.
---
 scripts/pkgorder |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/scripts/pkgorder b/scripts/pkgorder
index 7722718..aa67791 100755
--- a/scripts/pkgorder
+++ b/scripts/pkgorder
@@ -9,12 +9,11 @@
 # You should have received a copy of the GNU Library Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-import os.path
-import glob
+import os
+import fnmatch
 import rpm
 import rpmUtils
 import shutil
-import string
 import sys
 import yum
 
@@ -31,7 +30,6 @@ from optparse import OptionParser
 from yum.packageSack import PackageSack
 from yum.packages import PackageObject
 from yuminstall import YumSorter
-import iutil
 
 class PackageOrderer(YumSorter):
 
@@ -88,13 +86,9 @@ def processTransaction(ds):
 
 def printMatchingPkgs(fpattern):
     global processed
+    global packages
 
-    if os.path.isdir("%s/%s/RPMS" % (toppath, product)):
-        matches = glob.glob("%s/%s/RPMS/%s" % (toppath, product, fpattern))
-    elif os.path.isdir("%s/%s" %(toppath, product)):
-        matches = glob.glob("%s/%s/%s" % (toppath, product, fpattern))
-    else:
-        matches = glob.glob("%s/%s" % (toppath, fpattern))
+    matches = fnmatch.filter(packages, fpattern)
 
     for match in matches:
         mname = os.path.basename(match)
@@ -157,6 +151,15 @@ if __name__ == "__main__":
     if arch == "i386":
         arch = "i686"
 
+    packages = []
+    for dir in ("%s/%s/RPMS" % (toppath, product),
+                "%s/%s" % (toppath, product),
+                toppath):
+        if os.path.isdir(dir):
+            packages = os.listdir(dir)
+            break
+    packages.sort()
+
     # print out kernel related packages first
     printMatchingPkgs("kernel-*")
 
-- 
1.6.0.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux