File: main.py

package info (click to toggle)
crmsh 5.0.0~rc1-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 7,752 kB
  • sloc: python: 50,224; sh: 1,204; makefile: 254; xml: 243; exp: 234; awk: 22
file content (28 lines) | stat: -rw-r--r-- 714 bytes parent folder | download | duplicates (2)
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
from .parser import lexer, LookAheadIterator
from .generator import AsciiDocGenerator

from argparse import ArgumentParser
import sys

def main():
    ap = ArgumentParser('help2adoc')
    ap.add_argument('file')
    args = ap.parse_args()
    with open(args.file, 'r') as f:
        tokens = LookAheadIterator(lexer(f))
        AsciiDocGenerator(sys.stdout.write).parse_help(tokens)
        token = tokens.lookahead()
        if token is None:
            return
        epilog_start = token.lineno
        f.seek(0)
        for i in range(epilog_start):
            next(f)
        print('....')
        for line in f:
            print(line, end='')
        print('....')


if __name__ == '__main__':
    main()