summaryrefslogtreecommitdiff
path: root/tools/update-dbus-docs.py
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-08-27 19:27:18 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-08-27 20:22:52 +0200
commit0f5cea021252e1524776c992fb6a7bb1d55b1b51 (patch)
tree8d247eeac0fb59697d7b0e9698b7d1218d156b79 /tools/update-dbus-docs.py
parentaf4c7dc26936334f32b40bcd97bc6d8405011f68 (diff)
downloadsystemd-0f5cea021252e1524776c992fb6a7bb1d55b1b51.tar.gz
update-dbus-docs: use argparse
Diffstat (limited to 'tools/update-dbus-docs.py')
-rwxr-xr-xtools/update-dbus-docs.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/tools/update-dbus-docs.py b/tools/update-dbus-docs.py
index 8aa3742f60..bfe55220c1 100755
--- a/tools/update-dbus-docs.py
+++ b/tools/update-dbus-docs.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: LGPL-2.1+
+import argparse
import collections
import sys
import os
@@ -178,7 +179,7 @@ def subst_output(document, programlisting, stats):
node = programlisting.get('node')
interface = programlisting.get('interface')
- argv = [f'{build_dir}/{executable}', f'--bus-introspect={interface}']
+ argv = [f'{opts.build_dir}/{executable}', f'--bus-introspect={interface}']
print(f'COMMAND: {shlex.join(argv)}')
try:
@@ -275,19 +276,19 @@ def process(page):
return stats
-if __name__ == '__main__':
- pages = sys.argv[1:]
+def parse_args():
+ p = argparse.ArgumentParser()
+ p.add_argument('--build-dir', default='build')
+ p.add_argument('pages', nargs='+')
+ return p.parse_args()
- if pages[0].startswith('--build-dir='):
- build_dir = pages[0].partition('=')[2]
- pages = pages[1:]
- else:
- build_dir = 'build'
+if __name__ == '__main__':
+ opts = parse_args()
- if not os.path.exists(f'{build_dir}/systemd'):
- exit(f"{build_dir}/systemd doesn't exist. Use --build-dir=.")
+ if not os.path.exists(f'{opts.build_dir}/systemd'):
+ exit(f"{opts.build_dir}/systemd doesn't exist. Use --build-dir=.")
- stats = {page.split('/')[-1] : process(page) for page in pages}
+ stats = {page.split('/')[-1] : process(page) for page in opts.pages}
# Let's print all statistics at the end
mlen = max(len(page) for page in stats)