1
0
mirror of https://github.com/moparisthebest/xeps synced 2024-11-21 16:55:07 -05:00

tooling: print metadata extraction errors to stderr

This commit is contained in:
Jonas Wielicki 2017-08-23 16:33:28 +02:00
parent a455020d3a
commit 0ff93d4fa0

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python3
import pathlib
import sys
import xml.dom.minidom
import xml.etree.ElementTree as etree
@ -160,6 +161,8 @@ def main():
tree = etree.Element("xep-infos")
has_error = False
for xepfile in args.xepdir.glob("xep-*.xml"):
number = xepfile.name.split("-", 1)[1].split(".", 1)[0]
try:
@ -167,6 +170,7 @@ def main():
except ValueError:
continue
try:
with xepfile.open("rb") as f:
parsed = open_xml(f)
@ -175,10 +179,14 @@ def main():
extract_xep_metadata(parsed),
True,
))
except Exception as exc:
has_error = True
print("{}: {}".format(xepfile, exc), file=sys.stderr)
for xepfile in (args.xepdir / "inbox").glob("*.xml"):
protoname = xepfile.name.rsplit(".", 1)[0]
try:
with xepfile.open("rb") as f:
parsed = open_xml(f)
@ -188,6 +196,12 @@ def main():
False,
protoname=protoname
))
except Exception as exc:
has_error = True
print("{}: {}".format(xepfile, exc), file=sys.stderr)
if has_error:
sys.exit(2)
sys.stdout.buffer.raw.write(etree.tostring(tree))