1
0
forked from docs/doc-exports
doc-exports/process_links.py
Artem Goncharov d96bbbe08f Update conversion script
- drop line wrapping (leaves lines long, but at least doesn't corrup
  indentation)
- repair cross links by replacing them to the relative path of the new
  name
- further extend new name calculation
- add input path argument
2022-03-11 18:05:21 +01:00

26 lines
623 B
Python

#!/usr/bin/env python3
import json
import argparse
import subprocess
def main():
parser = argparse.ArgumentParser(description='Process links.')
parser.add_argument(
'path', type=str, help='path to the files')
args = parser.parse_args()
matrix = json.loads(open("matrix.json").read())
for k, v in matrix.items():
replace = v.replace('/', '\/')
subprocess.run(
f"find {args.path} -name *'.rst' -type f -print0 | xargs"
f" -0 sed -i '' 's/{k}/{replace}/g'",
shell=True
)
print(k, v)
if __name__ == "__main__":
main()