mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-09-10 21:45:21 +03:00
update-dbus-docs: use argparse
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# SPDX-License-Identifier: LGPL-2.1+
|
# SPDX-License-Identifier: LGPL-2.1+
|
||||||
|
|
||||||
|
import argparse
|
||||||
import collections
|
import collections
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
@@ -178,7 +179,7 @@ def subst_output(document, programlisting, stats):
|
|||||||
node = programlisting.get('node')
|
node = programlisting.get('node')
|
||||||
interface = programlisting.get('interface')
|
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)}')
|
print(f'COMMAND: {shlex.join(argv)}')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -275,19 +276,19 @@ def process(page):
|
|||||||
|
|
||||||
return stats
|
return stats
|
||||||
|
|
||||||
|
def parse_args():
|
||||||
|
p = argparse.ArgumentParser()
|
||||||
|
p.add_argument('--build-dir', default='build')
|
||||||
|
p.add_argument('pages', nargs='+')
|
||||||
|
return p.parse_args()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
pages = sys.argv[1:]
|
opts = parse_args()
|
||||||
|
|
||||||
if pages[0].startswith('--build-dir='):
|
if not os.path.exists(f'{opts.build_dir}/systemd'):
|
||||||
build_dir = pages[0].partition('=')[2]
|
exit(f"{opts.build_dir}/systemd doesn't exist. Use --build-dir=.")
|
||||||
pages = pages[1:]
|
|
||||||
else:
|
|
||||||
build_dir = 'build'
|
|
||||||
|
|
||||||
if not os.path.exists(f'{build_dir}/systemd'):
|
stats = {page.split('/')[-1] : process(page) for page in opts.pages}
|
||||||
exit(f"{build_dir}/systemd doesn't exist. Use --build-dir=.")
|
|
||||||
|
|
||||||
stats = {page.split('/')[-1] : process(page) for page in pages}
|
|
||||||
|
|
||||||
# Let's print all statistics at the end
|
# Let's print all statistics at the end
|
||||||
mlen = max(len(page) for page in stats)
|
mlen = max(len(page) for page in stats)
|
||||||
|
Reference in New Issue
Block a user