summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-09-18 18:51:42 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-09-18 18:51:42 +0200
commit8aaf611b9a38b6687427d2d8109f5d36570ef8de (patch)
tree7889cbfb7bb48179b9545e503bb9e2ce681ea809
parent4c8e5f442b5557a32e7d97f451d3d685f2fe26b9 (diff)
downloadsystemd-8aaf611b9a38b6687427d2d8109f5d36570ef8de.tar.gz
update-dbus-docs: skip test lxml is not available
-rwxr-xr-xtools/update-dbus-docs.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/tools/update-dbus-docs.py b/tools/update-dbus-docs.py
index 3500d9ce5e..255d7e180f 100755
--- a/tools/update-dbus-docs.py
+++ b/tools/update-dbus-docs.py
@@ -8,12 +8,11 @@ import os
import shlex
import subprocess
import io
-from lxml import etree
-PARSER = etree.XMLParser(no_network=True,
- remove_comments=False,
- strip_cdata=False,
- resolve_entities=False)
+try:
+ from lxml import etree
+except ModuleNotFoundError as e:
+ etree = e
class NoCommand(Exception):
pass
@@ -24,6 +23,12 @@ BORING_INTERFACES = [
'org.freedesktop.DBus.Properties',
]
+def xml_parser():
+ return etree.XMLParser(no_network=True,
+ remove_comments=False,
+ strip_cdata=False,
+ resolve_entities=False)
+
def print_method(declarations, elem, *, prefix, file, is_signal=False):
name = elem.get('name')
klass = 'signal' if is_signal else 'method'
@@ -186,7 +191,7 @@ def subst_output(document, programlisting, stats):
print(f'{executable} not found, ignoring', file=sys.stderr)
return
- xml = etree.fromstring(out, parser=PARSER)
+ xml = etree.fromstring(out, parser=xml_parser())
new_text, declarations, interfaces = xml_to_text(node, xml, only_interface=interface)
programlisting.text = '\n' + new_text + ' '
@@ -250,7 +255,7 @@ def subst_output(document, programlisting, stats):
def process(page):
src = open(page).read()
- xml = etree.fromstring(src, parser=PARSER)
+ xml = etree.fromstring(src, parser=xml_parser())
# print('parsing {}'.format(name), file=sys.stderr)
if xml.tag != 'refentry':
@@ -288,6 +293,10 @@ def parse_args():
if __name__ == '__main__':
opts = parse_args()
+ if isinstance(etree, Exception):
+ print(etree, file=sys.stderr)
+ exit(77 if opts.test else 1)
+
if not os.path.exists(f'{opts.build_dir}/systemd'):
exit(f"{opts.build_dir}/systemd doesn't exist. Use --build-dir=.")