diff options
author | Erik Troan <ewt@redhat.com> | 1999-05-05 18:22:56 +0000 |
---|---|---|
committer | Erik Troan <ewt@redhat.com> | 1999-05-05 18:22:56 +0000 |
commit | 8a6c57b804571f62794a03722e1e19be1c7bf690 (patch) | |
tree | 1a35687b6188e8dcb1632c3737cb5ada056b90ac /comps.py | |
parent | d2cd163beedf855c987e2b7cde4a179dd3716ddc (diff) | |
download | anaconda-8a6c57b804571f62794a03722e1e19be1c7bf690.tar.gz anaconda-8a6c57b804571f62794a03722e1e19be1c7bf690.tar.xz anaconda-8a6c57b804571f62794a03722e1e19be1c7bf690.zip |
provide a real headerlist object
Diffstat (limited to 'comps.py')
-rw-r--r-- | comps.py | 33 |
1 files changed, 22 insertions, 11 deletions
@@ -12,6 +12,27 @@ class Package: self.name = header[rpm.RPMTAG_NAME] self.selected = 0 +class HeaderList: + + def has_key(self, item): + return self.packages.has_key(item) + + def __getitem__(self, item): + return self.packages[item] + + def __init__(self, path): + hdlist = rpm.readHeaderList(path) + 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) + class Component: def __len__(self): @@ -105,7 +126,6 @@ class ComponentSet: self.compsDict[comp.name] = comp comp = None else: - if (l[0] == "@"): (at, l) = split(l, None, 1) comp.addInclude(self.compsDict[l]) @@ -127,14 +147,5 @@ class ComponentSet: def __init__(self, arch, file, hdlist): self.list = [] - 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) + self.packages = hdlist self.readCompsFile(arch, file, self.packages) |