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
精彩评论