mirror of
https://github.com/izzy2lost/ppsspp.git
synced 2026-03-10 12:43:04 -07:00
Update README following unknows markup way
This commit is contained in:
+34
-2
@@ -1,10 +1,42 @@
|
||||
#!/bin/python
|
||||
#!/usr/bin/env python
|
||||
|
||||
import re
|
||||
import time
|
||||
import urllib.request
|
||||
from urllib.error import HTTPError
|
||||
import time
|
||||
from lxml.html import parse
|
||||
|
||||
footer = ""
|
||||
def replace_foo(match):
|
||||
first_char = match.group(1)
|
||||
id = match.group(2)
|
||||
replace = first_char + "[#"+id+"][]"
|
||||
|
||||
url = "https://github.com/hrydgard/ppsspp/issues/"+id
|
||||
title = None
|
||||
while title is None:
|
||||
try:
|
||||
page = urllib.request.urlopen(url)
|
||||
p = parse(page)
|
||||
title = p.find(".//title").text.split('by')[0].split('·')[0].strip()
|
||||
title = re.sub(r"\"", r'\\"', title)
|
||||
except HTTPError:
|
||||
print("Something went wrong, retrying in 10 sec...")
|
||||
time.sleep(10)
|
||||
pass
|
||||
|
||||
global footer
|
||||
addition = "[#"+id+"]: https://github.com/hrydgard/ppsspp/issues/"+id+" \""+title+"\""
|
||||
print("Done: " + addition)
|
||||
footer += addition+"\n"
|
||||
return replace
|
||||
|
||||
f = open("README.md", "r+")
|
||||
cont = f.read()
|
||||
updated = re.sub(r"([^[])#(\d+)", r"\1[#\2](https://github.com/hrydgard/ppsspp/issues/\2)", cont)
|
||||
updated = re.sub(r"([^[])#(\d+)", replace_foo, cont)
|
||||
f.seek(0)
|
||||
f.write(updated)
|
||||
f.write(footer)
|
||||
f.truncate()
|
||||
f.close()
|
||||
|
||||
Reference in New Issue
Block a user