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
This commit is contained in:
Artem Goncharov 2022-03-11 18:02:51 +01:00
parent 446860da26
commit d96bbbe08f
4 changed files with 62 additions and 141 deletions

View File

@ -1 +0,0 @@
../../process.py

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

25
process_links.py Normal file
View File

@ -0,0 +1,25 @@
#!/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()