Encode properly in more places
This commit is contained in:
parent
98fce00720
commit
d532cf7eee
|
@ -139,25 +139,25 @@ def parse_lex_from_directory(directory):
|
||||||
path = directory + filename
|
path = directory + filename
|
||||||
# Read only .lex files
|
# Read only .lex files
|
||||||
if path[-4:] == ".lex":
|
if path[-4:] == ".lex":
|
||||||
print(" Parsing", path, end=" ")
|
print(" Parsing", path)
|
||||||
with open(path) as lex_file:
|
with open(path, "r", encoding="utf8") as lex_file:
|
||||||
lex_raw = lex_file.read()
|
lex_raw = lex_file.read()
|
||||||
parsed_lex = parse_lex(lex_raw)
|
parsed_lex = parse_lex(lex_raw)
|
||||||
if "error" in parsed_lex:
|
if "error" in parsed_lex:
|
||||||
print("ERROR:", parsed_lex["error"])
|
print(" ERROR:", parsed_lex["error"])
|
||||||
else:
|
else:
|
||||||
print("SUCCESS:", parsed_lex["title"])
|
print(" success:", parsed_lex["title"])
|
||||||
lexes.append(parsed_lex)
|
lexes.append(parsed_lex)
|
||||||
return lexes
|
return lexes
|
||||||
|
|
||||||
def load_resource(filename, cache={}):
|
def load_resource(filename, cache={}):
|
||||||
if filename not in cache:
|
if filename not in cache:
|
||||||
cache[filename] = open("resources/" + filename).read()
|
cache[filename] = open("resources/" + filename, "r", encoding="utf8").read()
|
||||||
return cache[filename]
|
return cache[filename]
|
||||||
|
|
||||||
def load_config():
|
def load_config():
|
||||||
config = {}
|
config = {}
|
||||||
with open("lexicon.cfg") as f:
|
with open("lexicon.cfg", "r", encoding="utf8") as f:
|
||||||
line = f.readline()
|
line = f.readline()
|
||||||
while line:
|
while line:
|
||||||
# Skim lines until a value definition begins
|
# Skim lines until a value definition begins
|
||||||
|
@ -512,7 +512,7 @@ def command_build(argv):
|
||||||
print("Writing written articles...")
|
print("Writing written articles...")
|
||||||
for lex in lexes:
|
for lex in lexes:
|
||||||
page = build_article_page(lex, cite_map, config)
|
page = build_article_page(lex, cite_map, config)
|
||||||
with io.open("out/" + lex["filename"] + ".html", "w", encoding="utf8") as f:
|
with open("out/" + lex["filename"] + ".html", "w", encoding="utf8") as f:
|
||||||
f.write(page)
|
f.write(page)
|
||||||
print(" Wrote " + lex["title"])
|
print(" Wrote " + lex["title"])
|
||||||
# Write the unwritten entries
|
# Write the unwritten entries
|
||||||
|
@ -521,14 +521,14 @@ def command_build(argv):
|
||||||
print("Writing phantom articles...")
|
print("Writing phantom articles...")
|
||||||
for title in phantom_entries:
|
for title in phantom_entries:
|
||||||
page = build_phantom_page(title, cite_map, config)
|
page = build_phantom_page(title, cite_map, config)
|
||||||
with io.open("out/" + as_filename(title) + ".html", "w") as f:
|
with open("out/" + as_filename(title) + ".html", "w", encoding="utf8") as f:
|
||||||
f.write(page)
|
f.write(page)
|
||||||
print(" Wrote " + title)
|
print(" Wrote " + title)
|
||||||
elif argv[2] == "full":
|
elif argv[2] == "full":
|
||||||
print("Writing stub articles...")
|
print("Writing stub articles...")
|
||||||
for title in phantom_entries:
|
for title in phantom_entries:
|
||||||
page = build_stub_page(title, cite_map, config)
|
page = build_stub_page(title, cite_map, config)
|
||||||
with io.open("out/" + as_filename(title) + ".html", "w") as f:
|
with open("out/" + as_filename(title) + ".html", "w", encoding="utf8") as f:
|
||||||
f.write(page)
|
f.write(page)
|
||||||
print(" Wrote " + title)
|
print(" Wrote " + title)
|
||||||
else:
|
else:
|
||||||
|
@ -537,23 +537,23 @@ def command_build(argv):
|
||||||
# Write the default pages
|
# Write the default pages
|
||||||
print("Writing default pages")
|
print("Writing default pages")
|
||||||
page = build_rules_page(config)
|
page = build_rules_page(config)
|
||||||
with io.open("out/rules.html", "w") as f:
|
with open("out/rules.html", "w", encoding="utf8") as f:
|
||||||
f.write(page)
|
f.write(page)
|
||||||
print(" Wrote Rules")
|
print(" Wrote Rules")
|
||||||
page = build_formatting_page(config)
|
page = build_formatting_page(config)
|
||||||
with io.open("out/formatting.html", "w") as f:
|
with open("out/formatting.html", "w", encoding="utf8") as f:
|
||||||
f.write(page)
|
f.write(page)
|
||||||
print(" Wrote Formatting")
|
print(" Wrote Formatting")
|
||||||
page = build_index_page(cite_map, config)
|
page = build_index_page(cite_map, config)
|
||||||
with io.open("out/index.html", "w") as f:
|
with open("out/index.html", "w", encoding="utf8") as f:
|
||||||
f.write(page)
|
f.write(page)
|
||||||
print(" Wrote Index")
|
print(" Wrote Index")
|
||||||
page = build_session_page(config)
|
page = build_session_page(config)
|
||||||
with io.open("out/session.html", "w") as f:
|
with open("out/session.html", "w", encoding="utf8") as f:
|
||||||
f.write(page)
|
f.write(page)
|
||||||
print(" Wrote Session")
|
print(" Wrote Session")
|
||||||
page = build_statistics_page(cite_map, config)
|
page = build_statistics_page(cite_map, config)
|
||||||
with io.open("out/stats.html", "w") as f:
|
with open("out/stats.html", "w", encoding="utf8") as f:
|
||||||
f.write(page)
|
f.write(page)
|
||||||
print(" Wrote Statistics")
|
print(" Wrote Statistics")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue