summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <pochu@debian.org>2020-12-01 14:01:36 +0100
committerEmilio Pozuelo Monfort <pochu@debian.org>2020-12-02 09:32:39 +0100
commit9b3a13e5d48024e62352b25d882708c3505e02f9 (patch)
treecc04366f533c50f64b6b02e4f183e3f81b3e669a /lib
parentf16a2a47dbea736d58438c0fba515533eb400b08 (diff)
sectracker.parsers: add function to write the file back
This change and the previous ones based on work by Brian with additional fixes and adaptations by me.
Diffstat (limited to 'lib')
-rw-r--r--lib/python/sectracker/parsers.py60
1 files changed, 60 insertions, 0 deletions
diff --git a/lib/python/sectracker/parsers.py b/lib/python/sectracker/parsers.py
index 42e7da75cb..7f0f1e3dad 100644
--- a/lib/python/sectracker/parsers.py
+++ b/lib/python/sectracker/parsers.py
@@ -1,5 +1,7 @@
# sectracker.parsers -- various text file parsers
# Copyright (C) 2010 Florian Weimer <fw@deneb.enyo.de>
+# Copyright (C) 2019 Brian May <bam@debian.org>
+# Copyright (C) 2020 Emilio Pozuelo Monfort <pochu@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -276,6 +278,64 @@ def cvelist(path, f):
return Bug(path, Header(headerlineno, name, desc), tuple(anns))
return _parselist(path, f, parseheader, finish)
+def writecvelist(data, f):
+ for bug in data:
+ if isinstance(bug, Bug):
+ f.write(bug.header.name)
+ if bug.header.description:
+ f.write(" ")
+ f.write(bug.header.description)
+ f.write("\n")
+ for annotation in bug.annotations:
+ if isinstance(annotation, FlagAnnotation):
+ f.write("\t")
+ f.write(annotation.type)
+ f.write("\n")
+ elif isinstance(annotation, StringAnnotation):
+ f.write("\t")
+ f.write(annotation.type)
+ f.write(": ")
+ f.write(annotation.description)
+ f.write("\n")
+ elif isinstance(annotation, PackageAnnotation):
+ f.write("\t")
+ if annotation.release:
+ f.write("[")
+ f.write(str(annotation.release))
+ f.write("] ")
+ f.write("- ")
+ f.write(annotation.package + " ")
+ if annotation.version:
+ f.write(annotation.version)
+ elif annotation.kind:
+ f.write("<")
+ f.write(annotation.kind)
+ f.write(">")
+ items = []
+ for flag in annotation.flags:
+ if isinstance(flag, PackageBugAnnotation):
+ items.append("bug #%s" % flag.bug)
+ elif isinstance(flag, PackageUrgencyAnnotation):
+ items.append(flag.severity)
+ else:
+ raise RuntimeError("Got unexpected package flag type %s" % type(flag))
+ if annotation.description:
+ items.append(str(annotation.description))
+ if items:
+ f.write(" (")
+ f.write("; ".join(items))
+ f.write(")")
+ f.write("\n")
+ elif isinstance(annotation, XrefAnnotation):
+ if annotation.bugs:
+ f.write("\t{")
+ f.write(" ".join(annotation.bugs))
+ f.write("}\n")
+ else:
+ raise RuntimeError("Got unexpected annotation type %s" % type(annotation))
+ else:
+ raise RuntimeError("Got unexpected bug type %s" % type(bug))
+
def _checkrelease(anns, diag, kind):
for ann in anns:
if ann.type == "package" and ann.release is None:

© 2014-2024 Faster IT GmbH | imprint | privacy policy