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