Constant used
[opentx.git] / tools / add-issue-links.py
blob582809885ba975ddc084aaaf1cfb3e3dc4f4c390
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
4 from __future__ import print_function
6 import sys
7 import re
10 if len(sys.argv) > 1:
11 inputFile = sys.argv[1]
12 inp = open(inputFile, "r")
13 else:
14 inp = sys.stdin
16 pattern = re.compile("#\d+")
17 while True:
18 skip = False
19 line = inp.readline()
20 if len(line) == 0:
21 break
22 line = line.strip('\r\n')
24 if len(line) == 0:
25 skip = True
26 if line.startswith("<"):
27 skip = True
28 if line.startswith("["):
29 skip = True
31 if not skip:
32 # line = line.strip()
33 # print("line: %s" % line)
34 found = re.findall(pattern, line)
35 if len(found) > 0:
36 for issue in found:
37 line = line.replace(issue, '')
38 # add issues
39 issue_links = ["<a href=https://github.com/opentx/opentx/issues/%d>#%d</a>" % (int(issue[1:]), int(issue[1:])) for issue in found]
40 links = "(" + ", ".join(issue_links) + ")"
41 line = "<li>" + line + " " + links + "</li>"
43 print(line)
46 inp.close()
47 sys.exit(0)