Paul Sokolovsky | a3814ac | 2022-09-06 15:51:01 +0300 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # Copyright (c) 2022 Arm Limited. All rights reserved. |
| 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | |
| 7 | # Script to replace absolute paths in ECLAIR HTML reports, pointing to |
| 8 | # "dependency" files like CSS & JS, to relative paths, pointing to |
| 9 | # those files copied alongside the report. |
| 10 | |
| 11 | import sys |
| 12 | import re |
| 13 | import os |
| 14 | import glob |
| 15 | |
| 16 | |
| 17 | os.chdir(sys.argv[1]) |
| 18 | for fn in glob.iglob("**/*.html", recursive=True): |
| 19 | depth = fn.count("/") |
| 20 | relp = "/".join([".."] * depth) |
| 21 | if relp: |
| 22 | relp += "/" |
| 23 | #print(fn, relp) |
| 24 | with open(fn) as f: |
| 25 | txt = f.read() |
| 26 | txt = txt.replace("/opt/bugseng/eclair-3.12.0/", relp) |
| 27 | #os.rename(fn, fn + ".bak") |
| 28 | with open(fn, "w") as f: |
| 29 | f.write(txt) |