-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdiff.py
More file actions
34 lines (25 loc) · 777 Bytes
/
diff.py
File metadata and controls
34 lines (25 loc) · 777 Bytes
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
import logging
import re
import sys
from argparse import ArgumentParser
from jinja2 import Template
def main():
p = ArgumentParser()
p.add_argument("template")
p.add_argument("names", nargs="+")
args = p.parse_args()
with open(args.template, "r") as f:
template = Template(f.read())
pages = []
for n in args.names:
with open(f"build/diff/{n}.html", "r") as f:
contents = f.readlines()
if len(contents) > 5:
pages.append({"name": n, "contents": "".join(contents)})
first = None
if pages:
first = pages.pop(0)
# sys.stdout.write("Content-Type: text/html\n\n")
sys.stdout.write(template.render(first=first, pages=pages))
if __name__ == '__main__':
main()