-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.py
42 lines (35 loc) · 1.26 KB
/
bootstrap.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import sys
from os.path import join, dirname, realpath
import re
def bootstrapXyJax():
searchString = "MathJax.Ajax.loadComplete(\"[MathJax]/extensions/TeX/xypic.js\");"
replaceString = "MathJax.Ajax.loadComplete(\"/js/XyJax/extensions/TeX/xypic.js\");"
replaceFileContent("js/XyJax/extensions/TeX/xypic.js", searchString, replaceString)
def replaceFileContent(relpath, searchString, replaceString):
path = join(bootstrapRoot, relpath)
f = open(path, "r")
content = f.read()
f.close()
content = content.replace(searchString, replaceString)
f = open(path, "w")
f.write(content)
f.close()
def replaceFileContentRegex(relpath, regex, replaceString):
path = join(bootstrapRoot, relpath)
f = open(path, "r")
content = f.read()
f.close()
content = re.sub(regex, replaceString, content)
f = open(path, "w")
f.write(content)
f.close()
if len(sys.argv) == 2:
host = sys.argv[1]
else:
host = "localhost/tag/"
currentpath = dirname(sys.argv[0])
bootstrapRoot = dirname(realpath('__file__'))
replaceFileContent("config.ini", "project = \"\"", "project = \"/var/www/html\"")
replaceFileContent("config.ini", "database = \"\"", "database = \"database/stacks.sqlite\"")
replaceFileContent("tex/scripts/tag_up.py", "http://stacks.math.columbia.edu/tag/", host)
bootstrapXyJax()