1
0
mirror of https://github.com/systemd/systemd synced 2025-09-30 09:14:46 +02:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Luca Boccassi
2a8e00846f
Merge pull request #18490 from keszybz/prettify-update-dbus-docs
Prettify update-dbus-docs
2021-02-06 15:36:39 +00:00
Zbigniew Jędrzejewski-Szmek
64eb60b8c5 update-dbus-docs: use color in summary 2021-02-06 11:41:42 +01:00
Zbigniew Jędrzejewski-Szmek
7bd5b8614d update-dbus-docs: say "MODIFIED" not "OUTDATED"
When executed in test mode, "OUTDATED" is appropriate. But when executed
to actually update the text, after the tool executes, those pages are the
opposite, not outdated.
2021-02-06 11:41:42 +01:00

View File

@ -31,6 +31,10 @@ BORING_INTERFACES = [
'org.freedesktop.DBus.Introspectable', 'org.freedesktop.DBus.Introspectable',
'org.freedesktop.DBus.Properties', 'org.freedesktop.DBus.Properties',
] ]
RED = '\x1b[31m'
GREEN = '\x1b[32m'
YELLOW = '\x1b[33m'
RESET = '\x1b[39m'
def xml_parser(): def xml_parser():
return etree.XMLParser(no_network=True, return etree.XMLParser(no_network=True,
@ -289,7 +293,7 @@ def process(page):
with open(page, 'w') as out: with open(page, 'w') as out:
out.write(out_text) out.write(out_text)
return dict(stats=stats, outdated=(out_text != src)) return dict(stats=stats, modified=(out_text != src))
def parse_args(): def parse_args():
p = argparse.ArgumentParser() p = argparse.ArgumentParser()
@ -317,17 +321,19 @@ if __name__ == '__main__':
# 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)
total = sum((item['stats'] for item in stats.values()), collections.Counter()) total = sum((item['stats'] for item in stats.values()), collections.Counter())
total = 'total', dict(stats=total, outdated=False) total = 'total', dict(stats=total, modified=False)
outdated = [] modified = []
classification = 'OUTDATED' if opts.test else 'MODIFIED'
for page, info in sorted(stats.items()) + [total]: for page, info in sorted(stats.items()) + [total]:
m = info['stats']['missing'] m = info['stats']['missing']
t = info['stats']['total'] t = info['stats']['total']
p = page + ':' p = page + ':'
c = 'OUTDATED' if info['outdated'] else '' c = classification if info['modified'] else ''
if c: if c:
outdated.append(page) modified.append(page)
print(f'{p:{mlen + 1}} {t - m}/{t} {c}') color = RED if m > t/2 else (YELLOW if m else GREEN)
print(f'{color}{p:{mlen + 1}} {t - m}/{t} {c}{RESET}')
if opts.test and outdated: if opts.test and modified:
exit(f'Outdated pages: {", ".join(outdated)}\n' exit(f'Outdated pages: {", ".join(modified)}\n'
f'Hint: ninja -C {opts.build_dir} update-dbus-docs') f'Hint: ninja -C {opts.build_dir} update-dbus-docs')