aboutsummaryrefslogtreecommitdiff
path: root/compile.py
diff options
context:
space:
mode:
authorIan Coleman <coleman.ian@gmail.com>2015-08-16 18:58:42 +1000
committerIan Coleman <coleman.ian@gmail.com>2015-08-16 19:03:05 +1000
commitab78acc683cf497b1b910e85fbbb77703401da6d (patch)
treed25b935649cc109f01066f7f7686202c86a7109b /compile.py
parentc90c680e13cc1c51f53479ed9427ca60c5ec5a0c (diff)
downloadBIP39-ab78acc683cf497b1b910e85fbbb77703401da6d.tar.gz
BIP39-ab78acc683cf497b1b910e85fbbb77703401da6d.tar.zst
BIP39-ab78acc683cf497b1b910e85fbbb77703401da6d.zip
compile.py generates bip39-standalone.html
Diffstat (limited to 'compile.py')
-rw-r--r--compile.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/compile.py b/compile.py
new file mode 100644
index 0000000..4d2dbe2
--- /dev/null
+++ b/compile.py
@@ -0,0 +1,48 @@
1import os
2import re
3import datetime
4
5# This script generates the bip39-standalone.html file.
6
7# It removes script and style tags and replaces with the file content.
8
9f = open('src/index.html')
10page = f.read()
11f.close()
12
13
14# Script tags
15
16scriptsFinder = re.compile("""<script src="/(.*)"></script>""")
17scripts = scriptsFinder.findall(page)
18
19for script in scripts:
20 filename = os.path.join("src", script)
21 s = open(filename)
22 scriptContent = "<script>%s</script>" % s.read()
23 s.close()
24 scriptTag = """<script src="/%s"></script>""" % script
25 page = page.replace(scriptTag, scriptContent)
26
27
28# Style tags
29
30stylesFinder = re.compile("""<link rel="stylesheet" href="/(.*)">""")
31styles = stylesFinder.findall(page)
32
33for style in styles:
34 filename = os.path.join("src", style)
35 s = open(filename)
36 styleContent = "<style>%s</style>" % s.read()
37 s.close()
38 styleTag = """<link rel="stylesheet" href="/%s">""" % style
39 page = page.replace(styleTag, styleContent)
40
41
42# Write the standalone file
43
44f = open('bip39-standalone.html', 'w')
45f.write(page)
46f.close()
47
48print "%s - DONE" % datetime.datetime.now()