summaryrefslogtreecommitdiffstats
path: root/comps.py
diff options
context:
space:
mode:
Diffstat (limited to 'comps.py')
-rw-r--r--comps.py25
1 files changed, 11 insertions, 14 deletions
diff --git a/comps.py b/comps.py
index 87bd73ac5..6aaa581e5 100644
--- a/comps.py
+++ b/comps.py
@@ -1,6 +1,7 @@
import rpm
from string import *
import types
+import urllib
class Package:
@@ -34,8 +35,7 @@ class HeaderList:
def __getitem__(self, item):
return self.packages[item]
- def __init__(self, path):
- hdlist = rpm.readHeaderListFromFile(path)
+ def __init__(self, hdlist):
self.hdlist = hdlist
self.packages = {}
for h in hdlist:
@@ -48,20 +48,16 @@ class HeaderList:
else:
self.packages[h[rpm.RPMTAG_NAME]] = Package(h)
+class HeaderListFromFile (HeaderList):
+
+ def __init__(self, path):
+ hdlist = rpm.readHeaderListFromFile(path)
+ HeaderList.__init__(self, hdlist)
+
class HeaderListFD (HeaderList):
def __init__(self, fd):
hdlist = rpm.readHeaderListFromFD (fd)
- self.hdlist = hdlist
- self.packages = {}
- for h in hdlist:
- name = h[rpm.RPMTAG_NAME]
- if self.packages.has_key(name):
- score1 = rpm.archscore(h[rpm.RPMTAG_ARCH])
- score2 = rpm.archscore(self.packages[name].h[rpm.RPMTAG_ARCH])
- if (score2 < score1):
- self.packages[h[rpm.RPMTAG_NAME]] = Package(h)
- else:
- self.packages[h[rpm.RPMTAG_NAME]] = Package(h)
+ HeaderList.__init__(self, hdlist)
class Component:
@@ -111,8 +107,9 @@ class ComponentSet:
return self.compsDict[key]
def readCompsFile(self, arch, filename, packages):
- file = open(filename, "r")
+ file = urllib.urlopen(filename)
lines = file.readlines()
+
file.close()
top = lines[0]
lines = lines[1:]