Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有YumRepository类的实例。有没有办法从我手动添加的存储库的配置文件中检索选项?
YumRepository
标准选项可用作实例的属性,YumRepository例如 rep.mirrorlist- 是镜像列表
rep.mirrorlist
在存储库配置文件中手动添加的选项名称是“notify=yes”,如何使用rep对象检索它的值。
rep
您有两个选择:在初始化 yum 之前破解 RepoConf 类,或者直接访问 RawConfigParser 对象。后者非常简单:
foo = repo.cfg.get(repo.id, 'foo')
第一个选项更复杂,但更通用:
from yum import config, YumBase config.RepoConf.foo = config.Option() yum = YumBase() for repo in yum.repos.listEnabled(): print repo.id, repo.foo