[Yum] pkgpolicy=(newest)|first|last by repo order in .conf

Cymon J. Cox cymon at duke.edu
Wed May 26 15:52:12 UTC 2004


Seeing as this has been discussed many times I'll get to the point: has
anyone considered poking an ordered dictionary through to ConfigParser?

Apart from touching a supposed private attribute (which I can live
with), this would seem to be a simple solution...

In yum/config.py:


class ConfigDictionary(dict):
    def __setitem__ (self, key, value):
        dict.__setitem__ (self, key, (len (self), value,))
    def __getitem__(self, key):
        return dict.__getitem__(self, key)[1]
    def ordered_sids(self):
        i = [(v, k) for (k, v) in self.items()]
        return [k for (v, k) in i]

class yumconf:

    def __init__(self, configfile = '/etc/yum.conf'):
        self.cfg = ConfigParser.ConfigParser()
        self.cfg._sections = ConfigDictionary() #!!!!!!

In yum/yummain.py

    serverlist = [sid for sid in conf.cfg._sections.ordered_sids() if
sid in conf.servers]
    if conf.pkgpolicy == 'first':
        conf.pkgpolicy = 'last'

    #serverlist = conf.servers


Cheers, C.
Cymon J. Cox <cymon at duke.edu>

More information about the Yum mailing list