[U] Create script to replace readme shorthand with links

This commit is contained in:
Azalea (on HyDEV-Daisy) 2022-07-31 16:03:26 -04:00
parent d13d737954
commit 19590d73b6
2 changed files with 61 additions and 40 deletions

View file

@ -0,0 +1,21 @@
#!/usr/bin/env python3
"""
This script turns readme shorthand pull request references (i.e. dylanaraps/neofetch#1946) into full
GitHub pull request links.
"""
import re
from pathlib import Path
RE_SHORTHAND = re.compile(r"""[a-z0-9]+?/[a-z0-9]+?#[0-9]+""")
if __name__ == '__main__':
readme = Path('README.md').read_text()
for shorthand in RE_SHORTHAND.findall(readme):
user, pull = shorthand.split('/')
repo, pull = pull.split('#')
readme = readme.replace(shorthand, f'[{user}#{pull}](https://github.com/{user}/{repo}/pull/{pull})')
Path('README.md').write_text(readme)