Override newline for file writes
This commit is contained in:
parent
309dc68127
commit
2a1c376c44
|
@ -136,13 +136,13 @@ def command_init(name):
|
||||||
# Edit the name field
|
# Edit the name field
|
||||||
config = re.sub("Lexicon Title", "Lexicon {}".format(name), config)
|
config = re.sub("Lexicon Title", "Lexicon {}".format(name), config)
|
||||||
# Create the Lexicon's config file
|
# Create the Lexicon's config file
|
||||||
with open(os.path.join(lex_path, "lexicon.cfg"), "w") as config_file:
|
with open(os.path.join(lex_path, "lexicon.cfg"), "w", newline='') as config_file:
|
||||||
config_file.write(config)
|
config_file.write(config)
|
||||||
# Copy the CSS file
|
# Copy the CSS file
|
||||||
with open(os.path.join(lex_path, "lexicon.css"), "w") as css_file:
|
with open(os.path.join(lex_path, "lexicon.css"), "w", newline='') as css_file:
|
||||||
css_file.write(utils.load_resource("lexicon.css"))
|
css_file.write(utils.load_resource("lexicon.css"))
|
||||||
# Create an example page
|
# Create an example page
|
||||||
with open(os.path.join(lex_path, "src", "example-page.txt"), "w") as destfile:
|
with open(os.path.join(lex_path, "src", "example-page.txt"), "w", newline='') as destfile:
|
||||||
destfile.write(utils.load_resource("example-page.txt"))
|
destfile.write(utils.load_resource("example-page.txt"))
|
||||||
# Create an empty status file
|
# Create an empty status file
|
||||||
open(os.path.join(lex_path, "status"), "w").close()
|
open(os.path.join(lex_path, "status"), "w").close()
|
||||||
|
|
|
@ -417,7 +417,7 @@ def build_all(path_prefix, lexicon_name):
|
||||||
|
|
||||||
# Write the redirect page
|
# Write the redirect page
|
||||||
print("Writing redirect page...")
|
print("Writing redirect page...")
|
||||||
with open(pathto("index.html"), "w", encoding="utf8") as f:
|
with open(pathto("index.html"), "w", encoding="utf8", newline='') as f:
|
||||||
f.write(utils.load_resource("redirect.html").format(
|
f.write(utils.load_resource("redirect.html").format(
|
||||||
lexicon=config["LEXICON_TITLE"], sort=config["DEFAULT_SORT"]))
|
lexicon=config["LEXICON_TITLE"], sort=config["DEFAULT_SORT"]))
|
||||||
|
|
||||||
|
@ -430,7 +430,7 @@ def build_all(path_prefix, lexicon_name):
|
||||||
l = len(articles)
|
l = len(articles)
|
||||||
for idx in range(l):
|
for idx in range(l):
|
||||||
article = articles[idx]
|
article = articles[idx]
|
||||||
with open(pathto("article", article.title_filesafe + ".html"), "w", encoding="utf-8") as f:
|
with open(pathto("article", article.title_filesafe + ".html"), "w", encoding="utf-8", newline='') as f:
|
||||||
content = article.build_default_content()
|
content = article.build_default_content()
|
||||||
article_html = page.format(
|
article_html = page.format(
|
||||||
title = article.title,
|
title = article.title,
|
||||||
|
@ -440,29 +440,29 @@ def build_all(path_prefix, lexicon_name):
|
||||||
|
|
||||||
# Write default pages
|
# Write default pages
|
||||||
print("Writing default pages...")
|
print("Writing default pages...")
|
||||||
with open(pathto("contents", "index.html"), "w", encoding="utf-8") as f:
|
with open(pathto("contents", "index.html"), "w", encoding="utf-8", newline='') as f:
|
||||||
f.write(build_contents_page(config, page, articles))
|
f.write(build_contents_page(config, page, articles))
|
||||||
print(" Wrote Contents")
|
print(" Wrote Contents")
|
||||||
with open(pathto("rules", "index.html"), "w", encoding="utf-8") as f:
|
with open(pathto("rules", "index.html"), "w", encoding="utf-8", newline='') as f:
|
||||||
f.write(build_rules_page(page))
|
f.write(build_rules_page(page))
|
||||||
print(" Wrote Rules")
|
print(" Wrote Rules")
|
||||||
with open(pathto("formatting", "index.html"), "w", encoding="utf-8") as f:
|
with open(pathto("formatting", "index.html"), "w", encoding="utf-8", newline='') as f:
|
||||||
f.write(build_formatting_page(page))
|
f.write(build_formatting_page(page))
|
||||||
print(" Wrote Formatting")
|
print(" Wrote Formatting")
|
||||||
with open(pathto("session", "index.html"), "w", encoding="utf-8") as f:
|
with open(pathto("session", "index.html"), "w", encoding="utf-8", newline='') as f:
|
||||||
f.write(build_session_page(page, config["SESSION_PAGE"]))
|
f.write(build_session_page(page, config["SESSION_PAGE"]))
|
||||||
print(" Wrote Session")
|
print(" Wrote Session")
|
||||||
with open(pathto("statistics", "index.html"), "w", encoding="utf-8") as f:
|
with open(pathto("statistics", "index.html"), "w", encoding="utf-8", newline='') as f:
|
||||||
f.write(build_statistics_page(config, page, articles))
|
f.write(build_statistics_page(config, page, articles))
|
||||||
print(" Wrote Statistics")
|
print(" Wrote Statistics")
|
||||||
|
|
||||||
# Write auxiliary pages
|
# Write auxiliary pages
|
||||||
if "PRINTABLE_FILE" in config and config["PRINTABLE_FILE"]:
|
if "PRINTABLE_FILE" in config and config["PRINTABLE_FILE"]:
|
||||||
with open(pathto(config["PRINTABLE_FILE"]), "w", encoding="utf-8") as f:
|
with open(pathto(config["PRINTABLE_FILE"]), "w", encoding="utf-8", newline='') as f:
|
||||||
f.write(build_compiled_page(articles, config))
|
f.write(build_compiled_page(articles, config))
|
||||||
print(" Wrote compiled page to " + config["PRINTABLE_FILE"])
|
print(" Wrote compiled page to " + config["PRINTABLE_FILE"])
|
||||||
|
|
||||||
with open(pathto("editor.html"), "w", encoding="utf-8") as f:
|
with open(pathto("editor.html"), "w", encoding="utf-8", newline='') as f:
|
||||||
editor = utils.load_resource("editor.html")
|
editor = utils.load_resource("editor.html")
|
||||||
writtenArticles = ""
|
writtenArticles = ""
|
||||||
phantomArticles = ""
|
phantomArticles = ""
|
||||||
|
|
Loading…
Reference in New Issue