/
githubmirror
/
librepo
Обзор
Документация
Войти
/
githubmirror
/
librepo
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/python/yum_repo_localisation.py
42 строки
1 KB
Daniel Alley
Drop Python 2 support
25 дек 2020, 21:25
25 дек 2020, 21:25
a67a128
Код
Авторство
О чём код?
#!/usr/bin/env python3 """ Example: Localize metadata files of a local repository Use case: We have a local repositository in the rpm-md format and want to paths to all its metadata files. Repomd content is just a bonus. """ import sys import librepo import pprint METADATA_PATH = "downloaded_metadata" if __name__ == "__main__": h = librepo.Handle() r = librepo.Result() # Repository with repodata in the rpm-md format h.setopt(librepo.LRO_REPOTYPE, librepo.LR_YUMREPO) # Path to metadata h.setopt(librepo.LRO_URLS, [METADATA_PATH]) # Do not duplicate (copy) metadata, just localise them h.setopt(librepo.LRO_LOCAL, True) try: h.perform(r) except librepo.LibrepoException as e: rc, msg, general_msg = e print("Error: {}".format(msg)) sys.exit(1) print("Repomd content:") pprint.pprint(r.getinfo(librepo.LRR_YUM_REPOMD)) print("\nPaths to metadata files:") for data_type, path in r.getinfo(librepo.LRR_YUM_REPO).iteritems(): print("%15s: %s" % (data_type, path)) sys.exit(0)