FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 02-25-2009, 02:02 PM
Martin Gracik
 
Default Rewrote parts of pkgorder script to improve it's speed. (#451083)

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@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 08:31 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org