1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

update-dbus-docs: skip test lxml is not available

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-09-18 18:51:42 +02:00
parent 4c8e5f442b
commit 8aaf611b9a

View File

@ -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=.")