summaryrefslogtreecommitdiffstats
path: root/tools/update-dbus-docs.py
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 /tools/update-dbus-docs.py
parentmeson: make "developer" mode the default (diff)
downloadsystemd-8aaf611b9a38b6687427d2d8109f5d36570ef8de.tar.xz
systemd-8aaf611b9a38b6687427d2d8109f5d36570ef8de.zip
update-dbus-docs: skip test lxml is not available
Diffstat (limited to 'tools/update-dbus-docs.py')
-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=.")