]>
Commit | Line | Data |
---|---|---|
ab78acc6 IC |
1 | import os |
2 | import re | |
3 | import datetime | |
a40d59d9 | 4 | from 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 | 10 | f = open('src/index.html', "r", encoding="utf-8") |
ab78acc6 IC |
11 | page = f.read() |
12 | f.close() | |
13 | ||
14 | ||
15 | # Script tags | |
16 | ||
cee442b1 | 17 | scriptsFinder = re.compile("""<script src="(.*)"></script>""") |
ab78acc6 IC |
18 | scripts = scriptsFinder.findall(page) |
19 | ||
20 | for 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 | 31 | stylesFinder = re.compile("""<link rel="stylesheet" href="(.*)">""") |
ab78acc6 IC |
32 | styles = stylesFinder.findall(page) |
33 | ||
34 | for 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 | 45 | f = open('bip39-standalone.html', 'w', encoding="utf-8") |
ab78acc6 IC |
46 | f.write(page) |
47 | f.close() | |
48 | ||
10cb3cc0 | 49 | print("%s - DONE" % datetime.datetime.now()) |