2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-31 22:35:36 +00:00

Force UTF-8 encoding when r/w'ing text files

This commit is contained in:
Dan
2018-01-21 16:56:50 +01:00
parent 564725a68e
commit c7d2de3ee9
5 changed files with 28 additions and 28 deletions

View File

@@ -44,7 +44,7 @@ def generate(source_path, base):
if not i.startswith("__"):
build("/".join([path, i]), level=level + 1)
except NotADirectoryError:
with open(path + "/" + i) as f:
with open(path + "/" + i, encoding="utf-8") as f:
p = ast.parse(f.read())
for node in ast.walk(p):
@@ -59,7 +59,7 @@ def generate(source_path, base):
os.makedirs(os.path.dirname(destination + "/" + full_path), exist_ok=True)
with open(destination + "/" + full_path, "w") as f:
with open(destination + "/" + full_path, "w", encoding="utf-8") as f:
f.write(
page_template.format(
title=name,
@@ -94,7 +94,7 @@ def generate(source_path, base):
inner_path = base + "/index" + ".rst"
module = "pyrogram.api.{}".format(base)
with open(destination + "/" + inner_path, "w") as f:
with open(destination + "/" + inner_path, "w", encoding="utf-8") as f:
f.write(
toctree.format(
title=k.title(),
@@ -111,10 +111,10 @@ def start():
global page_template
global toctree
with open(home + "/template/page.txt") as f:
with open(home + "/template/page.txt", encoding="utf-8") as f:
page_template = f.read()
with open(home + "/template/toctree.txt") as f:
with open(home + "/template/toctree.txt", encoding="utf-8") as f:
toctree = f.read()
generate(types_path, types_base)