]>
Commit | Line | Data |
---|---|---|
ab78acc6 IC |
1 | import os |
2 | import re | |
3 | import 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 | ||
ed5c77c4 | 9 | f = open('src/index.html', "r", encoding="utf-8") |
ab78acc6 IC |
10 | page = f.read() |
11 | f.close() | |
12 | ||
13 | ||
14 | # Script tags | |
15 | ||
cee442b1 | 16 | scriptsFinder = re.compile("""<script src="(.*)"></script>""") |
ab78acc6 IC |
17 | scripts = scriptsFinder.findall(page) |
18 | ||
19 | for script in scripts: | |
20 | filename = os.path.join("src", script) | |
ed5c77c4 | 21 | s = open(filename, "r", encoding="utf-8") |
ab78acc6 IC |
22 | scriptContent = "<script>%s</script>" % s.read() |
23 | s.close() | |
cee442b1 | 24 | scriptTag = """<script src="%s"></script>""" % script |
ab78acc6 IC |
25 | page = page.replace(scriptTag, scriptContent) |
26 | ||
27 | ||
28 | # Style tags | |
29 | ||
cee442b1 | 30 | stylesFinder = re.compile("""<link rel="stylesheet" href="(.*)">""") |
ab78acc6 IC |
31 | styles = stylesFinder.findall(page) |
32 | ||
33 | for style in styles: | |
34 | filename = os.path.join("src", style) | |
ed5c77c4 | 35 | s = open(filename, "r", encoding="utf-8") |
ab78acc6 IC |
36 | styleContent = "<style>%s</style>" % s.read() |
37 | s.close() | |
cee442b1 | 38 | styleTag = """<link rel="stylesheet" href="%s">""" % style |
ab78acc6 IC |
39 | page = page.replace(styleTag, styleContent) |
40 | ||
41 | ||
42 | # Write the standalone file | |
43 | ||
ed5c77c4 | 44 | f = open('bip39-standalone.html', 'w', encoding="utf-8") |
ab78acc6 IC |
45 | f.write(page) |
46 | f.close() | |
47 | ||
10cb3cc0 | 48 | print("%s - DONE" % datetime.datetime.now()) |