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:
@@ -70,15 +70,15 @@ def start():
|
||||
shutil.rmtree("{}/types".format(DESTINATION), ignore_errors=True)
|
||||
shutil.rmtree("{}/functions".format(DESTINATION), ignore_errors=True)
|
||||
|
||||
with open("{}/source/auth_key.tl".format(HOME)) as auth, \
|
||||
open("{}/source/sys_msgs.tl".format(HOME)) as system, \
|
||||
open("{}/source/main_api.tl".format(HOME)) as api:
|
||||
with open("{}/source/auth_key.tl".format(HOME), encoding="utf-8") as auth, \
|
||||
open("{}/source/sys_msgs.tl".format(HOME), encoding="utf-8") as system, \
|
||||
open("{}/source/main_api.tl".format(HOME), encoding="utf-8") as api:
|
||||
schema = (auth.read() + system.read() + api.read()).splitlines()
|
||||
|
||||
with open("{}/template/class.txt".format(HOME)) as f:
|
||||
with open("{}/template/class.txt".format(HOME), encoding="utf-8") as f:
|
||||
template = f.read()
|
||||
|
||||
with open(notice_path) as f:
|
||||
with open(notice_path, encoding="utf-8") as f:
|
||||
notice = []
|
||||
|
||||
for line in f.readlines():
|
||||
@@ -162,10 +162,10 @@ def start():
|
||||
init = "{}/__init__.py".format(path)
|
||||
|
||||
if not os.path.exists(init):
|
||||
with open(init, "w") as f:
|
||||
with open(init, "w", encoding="utf-8") as f:
|
||||
f.write(notice + "\n\n")
|
||||
|
||||
with open(init, "a") as f:
|
||||
with open(init, "a", encoding="utf-8") as f:
|
||||
f.write("from .{} import {}\n".format(snek(c.name), capit(c.name)))
|
||||
|
||||
sorted_args = sort_args(c.args)
|
||||
@@ -397,7 +397,7 @@ def start():
|
||||
read_types += "\n "
|
||||
read_types += "{} = Object.read(b)\n ".format(arg_name)
|
||||
|
||||
with open("{}/{}.py".format(path, snek(c.name)), "w") as f:
|
||||
with open("{}/{}.py".format(path, snek(c.name)), "w", encoding="utf-8") as f:
|
||||
f.write(
|
||||
template.format(
|
||||
notice=notice,
|
||||
@@ -414,7 +414,7 @@ def start():
|
||||
)
|
||||
)
|
||||
|
||||
with open("{}/all.py".format(DESTINATION), "w") as f:
|
||||
with open("{}/all.py".format(DESTINATION), "w", encoding="utf-8") as f:
|
||||
f.write(notice + "\n\n")
|
||||
f.write("layer = {}\n\n".format(layer))
|
||||
f.write("objects = {")
|
||||
@@ -436,7 +436,7 @@ def start():
|
||||
f.write("\n}\n")
|
||||
|
||||
for k, v in namespaces.items():
|
||||
with open("{}/{}/__init__.py".format(DESTINATION, k), "a") as f:
|
||||
with open("{}/{}/__init__.py".format(DESTINATION, k), "a", encoding="utf-8") as f:
|
||||
f.write("from . import {}\n".format(", ".join([i for i in v])) if v else "")
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user