-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathreplaceInHtml.py
More file actions
24 lines (19 loc) · 810 Bytes
/
replaceInHtml.py
File metadata and controls
24 lines (19 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python3
import os.path
replaceItems = {
"<h3 class='mb0 no-anchor'>seisplotjs.":"<h3 class='mb0 no-anchor'><a href=\"index.html\">seisplotjs</a>.",
"https://git@github.com/:crotwell": "https://github.com/crotwell"
}
for dirpath, dirs, files in os.walk('docs/api'):
for filename in files:
if filename.endswith('.html') and filename != "index.html":
# Read in the file
filepath = os.path.join(dirpath, filename)
with open(filepath, 'r') as file :
filedata = file.read()
# Replace the target string
for k, v in replaceItems.items():
filedata = filedata.replace(k, v)
# Write the file out again
with open(filepath, 'w') as file:
file.write(filedata)