File: repomd_parsing.py

package info (click to toggle)
createrepo-c 1.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,632 kB
  • sloc: ansic: 31,242; python: 4,868; xml: 2,669; sh: 363; makefile: 26; perl: 7
file content (37 lines) | stat: -rwxr-xr-x 1,168 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python3

import os
import os.path

import createrepo_c as cr

REPO_PATH = "repo/"

def parse_repomd(path):
    repomd = cr.Repomd(path)
    print("Revision:", repomd.revision)
    if repomd.contenthash:
        print("Contenthash:", repomd.contenthash)
        print("Contenthash type:", repomd.contenthash_type)
    print("Repo tags:", repomd.repo_tags)
    print("Content tags:", repomd.content_tags)
    print("Distro tags:", repomd.distro_tags)
    print()
    for rec in repomd.records:
        print("Type:", rec.type)
        print("Location href:", rec.location_href)
        print("Location base:", rec.location_base)
        print("Checksum:", rec.checksum)
        print("Checksum type:", rec.checksum_type)
        print("Checksum open:", rec.checksum_open)
        print("Checksum open type:", rec.checksum_open_type)
        print("Timestamp:", rec.timestamp)
        print("Size:", rec.size)
        print("Size open:", rec.size_open)
        if rec.db_ver:
            print("Db version:", rec.db_ver)
        print()

if __name__ == "__main__":
    repomd_path = os.path.join(REPO_PATH, "repodata/repomd.xml")
    parse_repomd(repomd_path)