2022-07-31 14:03:26 -06:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
"""
|
|
|
|
This script turns readme shorthand pull request references (i.e. dylanaraps/neofetch#1946) into full
|
|
|
|
GitHub pull request links.
|
|
|
|
"""
|
2023-02-21 07:55:14 -07:00
|
|
|
import regex as re
|
2022-07-31 14:03:26 -06:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
2023-02-21 07:51:27 -07:00
|
|
|
RE_SHORTHAND = re.compile(r"(\w+?)/(\w+?)#(\d+)")
|
2023-02-21 07:55:14 -07:00
|
|
|
MY_RE = re.compile(r"(?<=[^\w\[])#(\d+)")
|
2022-07-31 14:03:26 -06:00
|
|
|
|
|
|
|
|
2022-09-06 09:30:51 -06:00
|
|
|
def reformat_readme():
|
2022-07-31 14:03:26 -06:00
|
|
|
readme = Path('README.md').read_text()
|
|
|
|
|
2023-02-21 07:51:27 -07:00
|
|
|
readme = re.sub(RE_SHORTHAND, r'[\1#\3](https://github.com/\1/\2/pull/\3)', readme)
|
|
|
|
readme = re.sub(MY_RE, r'[#\1](https://github.com/hykilpikonna/hyfetch/pull/\1)', readme)
|
2022-07-31 14:03:26 -06:00
|
|
|
|
|
|
|
Path('README.md').write_text(readme)
|
2022-09-06 09:30:51 -06:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
reformat_readme()
|