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