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:
parent
a455020d3a
commit
0ff93d4fa0
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import sys
|
||||||
import xml.dom.minidom
|
import xml.dom.minidom
|
||||||
|
|
||||||
import xml.etree.ElementTree as etree
|
import xml.etree.ElementTree as etree
|
||||||
@ -160,6 +161,8 @@ def main():
|
|||||||
|
|
||||||
tree = etree.Element("xep-infos")
|
tree = etree.Element("xep-infos")
|
||||||
|
|
||||||
|
has_error = False
|
||||||
|
|
||||||
for xepfile in args.xepdir.glob("xep-*.xml"):
|
for xepfile in args.xepdir.glob("xep-*.xml"):
|
||||||
number = xepfile.name.split("-", 1)[1].split(".", 1)[0]
|
number = xepfile.name.split("-", 1)[1].split(".", 1)[0]
|
||||||
try:
|
try:
|
||||||
@ -167,27 +170,38 @@ def main():
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
with xepfile.open("rb") as f:
|
try:
|
||||||
parsed = open_xml(f)
|
with xepfile.open("rb") as f:
|
||||||
|
parsed = open_xml(f)
|
||||||
|
|
||||||
tree.append(make_metadata_element(
|
tree.append(make_metadata_element(
|
||||||
number,
|
number,
|
||||||
extract_xep_metadata(parsed),
|
extract_xep_metadata(parsed),
|
||||||
True,
|
True,
|
||||||
))
|
))
|
||||||
|
except Exception as exc:
|
||||||
|
has_error = True
|
||||||
|
print("{}: {}".format(xepfile, exc), file=sys.stderr)
|
||||||
|
|
||||||
for xepfile in (args.xepdir / "inbox").glob("*.xml"):
|
for xepfile in (args.xepdir / "inbox").glob("*.xml"):
|
||||||
protoname = xepfile.name.rsplit(".", 1)[0]
|
protoname = xepfile.name.rsplit(".", 1)[0]
|
||||||
|
|
||||||
with xepfile.open("rb") as f:
|
try:
|
||||||
parsed = open_xml(f)
|
with xepfile.open("rb") as f:
|
||||||
|
parsed = open_xml(f)
|
||||||
|
|
||||||
tree.append(make_metadata_element(
|
tree.append(make_metadata_element(
|
||||||
"xxxx",
|
"xxxx",
|
||||||
extract_xep_metadata(parsed),
|
extract_xep_metadata(parsed),
|
||||||
False,
|
False,
|
||||||
protoname=protoname
|
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))
|
sys.stdout.buffer.raw.write(etree.tostring(tree))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user