forked from singularityware/singularityware.github.io
-
Notifications
You must be signed in to change notification settings - Fork 1
/
circle_urls.py
24 lines (20 loc) · 805 Bytes
/
circle_urls.py
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 python
'''
circle_urls.py will rename all url files to not have extension .html
'''
import sys
import os
from glob import glob
site_dir = os.path.abspath(sys.argv[1])
print("Using site directory %s" %(site_dir))
files = glob("%s/*.html" %(site_dir))
# For each file, we need to replace all links to have correct .html extension
search_names = [os.path.basename(f).replace('.html','') for f in files]
for html_file in files:
with open(html_file,'r') as filey:
content = filey.read()
for search_name in search_names:
content = content.replace('%s"' %(search_name),'%s.html"' %(search_name))
content = content.replace('/images/logo/logo.svg','http://singularity.lbl.gov/images/logo/logo.svg')
with open(html_file,'w') as filey:
filey.write(content)