1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-15 20:35:17 +03:00
opentx/radio/util/add-issue-links.py
Sean Vig 5efa5d47d3 Use Python 2/3 compatible scripts
Almost entirely fixing print statements, but also a couple importing
changes, wrapped in try/excepts, and one case where dict.keys() not
being a list would be a problem.

Also reverts e41139a397

The real fix for #1907
2015-12-13 18:28:44 -06:00

51 lines
1,018 B
Python
Executable file

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import sys
import os
import traceback
import time
import re
import re
if len(sys.argv) > 1:
inputFile = sys.argv[1]
inp = open(inputFile, "r")
else:
inp = sys.stdin
pattern = re.compile("#\d+")
while True:
skip = False
line = inp.readline()
if len(line) == 0:
break
line = line.strip('\r\n')
if len(line) == 0:
skip = True
if line.startswith("<"):
skip = True
if line.startswith("["):
skip = True
if not skip:
#line = line.strip()
#print "line: %s" % line
found = re.findall(pattern, line)
if len(found) > 0:
for issue in found:
line = line.replace(issue, '')
#add issues
issue_links = ["<a href=https://github.com/opentx/opentx/issues/%d>#%d</a>" % (int(issue[1:]), int(issue[1:])) for issue in found]
links = "(" + ", ".join(issue_links) + ")"
line = "<li>" + line + " " + links + "</li>"
print(line)
inp.close()
sys.exit(0)