开发者

Yum : How to retrieve option value from repositories configuration using python

I have instance开发者_JAVA百科 of YumRepository class. Is there a way to retrieve the option from configuration file of a repository, that I've added manually ?

Standard options are available as attributes of YumRepository instance e.g. rep.mirrorlist - is the list of mirrors

Manually added option name in repositories config file is "notify=yes", how to retrieve it's value using rep object.


You have two options: either hack RepoConf class before initializing yum, or use direct access to RawConfigParser object. The latter is quite simple:

foo = repo.cfg.get(repo.id, 'foo')

First option is more complicated, but more universal:

from yum import config, YumBase

config.RepoConf.foo = config.Option()

yum = YumBase()
for repo in yum.repos.listEnabled():
    print repo.id, repo.foo
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜