File: check_manfile.py

package info (click to toggle)
zmap 4.3.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,628 kB
  • sloc: ansic: 15,033; python: 1,085; yacc: 125; sh: 120; lex: 28; makefile: 4
file content (38 lines) | stat: -rwxr-xr-x 1,018 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
#
# CI runs this script to verify that options appearing in ZTools' ggo.in files
# also appear in their .ronn files.  It does not check that `make manpages` has
# actually been run.
#
# This script assumes it's being run from the root of the zmap repository.
#

import sys

checks = [
    ("zopt.ggo.in", "zmap.1.ronn"),
    ("zbopt.ggo.in", "zblocklist.1.ronn"),
    ("zitopt.ggo.in", "ziterate.1.ronn"),
    ("ztopt.ggo.in", "ztee.1.ronn")
]

failures = False

for ggo, ronn in checks:
    options = []
    with open("src/" + ggo) as fd:
        for l in fd:
            if l.startswith("option "):
                option = l.split()[1].lstrip('"').rstrip('"')
                options.append(option)

    man = open("src/" + ronn).read()

    for option in options:
        if option not in man:
            failures = True
            sys.stderr.write(f"option \"{option}\" is present in \"{ggo}\" but missing from man file \"{ronn}\"\n")
    sys.stderr.flush()

if failures:
    sys.exit(1)