summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Boccassi <luca.boccassi@microsoft.com>2021-01-19 12:57:46 +0100
committerLuca Boccassi <luca.boccassi@microsoft.com>2021-01-29 10:53:34 +0100
commit668b3a42fe9e250912bd3efa4460ed691452d9bf (patch)
tree0d7556e69db96a67d4d416606d27eb48735018e9
parentci: build the Fedora RPMs with -Werror (diff)
downloadsystemd-668b3a42fe9e250912bd3efa4460ed691452d9bf.tar.xz
systemd-668b3a42fe9e250912bd3efa4460ed691452d9bf.zip
tools: make update-dbus-docs compatible with Python 3.7
Debian Stable uses Python 3.7, but there are a couple of 3.8 features used in the script. Add fallbacks.
-rwxr-xr-xtools/update-dbus-docs.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/tools/update-dbus-docs.py b/tools/update-dbus-docs.py
index ebe67af836..269b2196a2 100755
--- a/tools/update-dbus-docs.py
+++ b/tools/update-dbus-docs.py
@@ -18,6 +18,11 @@ try:
except ImportError as e:
shlex_join = e
+try:
+ from shlex import quote as shlex_quote
+except ImportError as e:
+ shlex_quote = e
+
class NoCommand(Exception):
pass
@@ -186,7 +191,10 @@ def subst_output(document, programlisting, stats):
interface = programlisting.get('interface')
argv = [f'{opts.build_dir}/{executable}', f'--bus-introspect={interface}']
- print(f'COMMAND: {shlex_join(argv)}')
+ if isinstance(shlex_join, Exception):
+ print(f'COMMAND: {" ".join(shlex_quote(arg) for arg in argv)}')
+ else:
+ print(f'COMMAND: {shlex_join(argv)}')
try:
out = subprocess.check_output(argv, text=True)
@@ -296,7 +304,7 @@ def parse_args():
if __name__ == '__main__':
opts = parse_args()
- for item in (etree, shlex_join):
+ for item in (etree, shlex_quote):
if isinstance(item, Exception):
print(item, file=sys.stderr)
exit(77 if opts.test else 1)
@@ -308,7 +316,7 @@ if __name__ == '__main__':
# Let's print all statistics at the end
mlen = max(len(page) for page in stats)
- total = sum((item['stats'] for item in stats.values()), start=collections.Counter())
+ total = sum((item['stats'] for item in stats.values()), collections.Counter())
total = 'total', dict(stats=total, outdated=False)
outdated = []
for page, info in sorted(stats.items()) + [total]: