summaryrefslogtreecommitdiff
path: root/old/architecture/extract_excerpts.py
blob: cd7bc11326c24141eb5ede9b34048f85af85cb54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python3

if __name__ == '__main__':
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('id', type=str)
    parser.add_argument('infile', type=argparse.FileType('r'), nargs='+')
    args = parser.parse_args()

    for f in args.infile:
        with f:
            marker = 'BEGIN EXCERPT {}'.format(args.id)
            for line in f:
                if marker in line:
                    break

            marker = 'END EXCERPT {}'.format(args.id)
            for line in f:
                if marker in line:
                    break
                print(line.rstrip())