]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blame - compile.py
Merge branch 'master' into master
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / compile.py
CommitLineData
ab78acc6
IC
1import os
2import re
3import datetime
a40d59d9 4from io import open
ab78acc6
IC
5
6# This script generates the bip39-standalone.html file.
7
8# It removes script and style tags and replaces with the file content.
9
ed5c77c4 10f = open('src/index.html', "r", encoding="utf-8")
ab78acc6
IC
11page = f.read()
12f.close()
13
14
15# Script tags
16
cee442b1 17scriptsFinder = re.compile("""<script src="(.*)"></script>""")
ab78acc6
IC
18scripts = scriptsFinder.findall(page)
19
20for script in scripts:
21 filename = os.path.join("src", script)
ed5c77c4 22 s = open(filename, "r", encoding="utf-8")
ab78acc6
IC
23 scriptContent = "<script>%s</script>" % s.read()
24 s.close()
cee442b1 25 scriptTag = """<script src="%s"></script>""" % script
ab78acc6
IC
26 page = page.replace(scriptTag, scriptContent)
27
28
29# Style tags
30
cee442b1 31stylesFinder = re.compile("""<link rel="stylesheet" href="(.*)">""")
ab78acc6
IC
32styles = stylesFinder.findall(page)
33
34for style in styles:
35 filename = os.path.join("src", style)
ed5c77c4 36 s = open(filename, "r", encoding="utf-8")
ab78acc6
IC
37 styleContent = "<style>%s</style>" % s.read()
38 s.close()
cee442b1 39 styleTag = """<link rel="stylesheet" href="%s">""" % style
ab78acc6
IC
40 page = page.replace(styleTag, styleContent)
41
42
43# Write the standalone file
44
ed5c77c4 45f = open('bip39-standalone.html', 'w', encoding="utf-8")
ab78acc6
IC
46f.write(page)
47f.close()
48
10cb3cc0 49print("%s - DONE" % datetime.datetime.now())