File: updateinfo_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 (60 lines) | stat: -rwxr-xr-x 2,454 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/python3

import os
import os.path
import optparse

import createrepo_c as cr


def parse_updateinfo(path):
    uinfo = cr.UpdateInfo(path)
    for update in uinfo.updates:
        print("From:         %s" % update.fromstr)
        print("Status:       %s" % update.status)
        print("Type:         %s" % update.type)
        print("Version:      %s" % update.version)
        print("Id:           %s" % update.id)
        print("Title:        %s" % update.title)
        print("Issued date:  %s" % update.issued_date)
        print("Updated date: %s" % update.updated_date)
        print("Rights:       %s" % update.rights)
        print("Release:      %s" % update.release)
        print("Pushcount:    %s" % update.pushcount)
        print("Severity:     %s" % update.severity)
        print("Summary:      %s" % update.summary)
        print("Description:  %s" % update.description)
        print("Solution:     %s" % update.solution)
        print("References:")
        for ref in update.references:
            print("  Href:  %s" % ref.href)
            print("  Id:    %s" % ref.id)
            print("  Type:  %s" % ref.type)
            print("  Title: %s" % ref.title)
            print("  ----------------------------")
        print("Pkglist (collections):")
        for col in update.collections:
            print("  Short: %s" % col.shortname)
            print("  name:  %s" % col.name)
            print("  Packages:")
            for pkg in col.packages:
                print("    Name:     %s" % pkg.name)
                print("    Version:  %s" % pkg.version)
                print("    Release:  %s" % pkg.release)
                print("    Epoch:    %s" % pkg.epoch)
                print("    Arch:     %s" % pkg.arch)
                print("    Src:      %s" % pkg.src)
                print("    Filename: %s" % pkg.filename)
                print("    Sum:      %s" % pkg.sum)
                print("    Sum type: %s (%s)" % (pkg.sum_type, cr.checksum_name_str(pkg.sum_type)))
                print("    Reboot suggested: %s" % pkg.reboot_suggested)
            print("  ----------------------------")
        print("==============================")


if __name__ == "__main__":
    parser = optparse.OptionParser(usage="%prog PATH_TO_UPDATEINFO")
    options, args = parser.parse_args()
    if len(args) != 1:
        parser.error("You have to specify exactly one update info")
    parse_updateinfo(args[0])