Skip to content

Commit

Permalink
always add no edit comment to produced files
Browse files Browse the repository at this point in the history
  • Loading branch information
burner1024 committed Aug 24, 2023
1 parent e19ddd5 commit 2decc0e
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@
"uk_UA": "cp1251",
}

COMMENT_NO_MANUAL = (
"// Do not edit manually. This file is generated automatically by handle-charsets. Your changes will be lost.\n\n"
)


def resave_file(src_path, src_enc, dst_path, dst_enc, split_console=False):
def resave_file(src_path, src_enc, dst_path, dst_enc):
"""
Read source file with source encoding and save it to destination with another encoding
"""
Expand All @@ -84,12 +88,6 @@ def resave_file(src_path, src_enc, dst_path, dst_enc, split_console=False):
os.remove(dst_dir)
os.makedirs(dst_dir)

if split_console:
data = (
"// Do not edit manually. "
"This file is generated automatically by handle-charsets. "
"Your changes will be lost.\n\n" + data
)
with open(dst_path, mode="w", encoding=dst_enc) as ofile:
ofile.write(data)

Expand Down Expand Up @@ -212,10 +210,10 @@ def main():

if args.split_console and filename in CONSOLE_FILES:
console_out_file = get_os_path(tra_out_file, "win32")
resave_file(tra_file, src_encoding, console_out_file, dst_encoding, split_console=True)
resave_file(tra_file, src_encoding, console_out_file, dst_encoding)
for weidu_os in ["unix", "osx"]:
console_out_file = get_os_path(tra_out_file, weidu_os)
resave_file(tra_file, src_encoding, console_out_file, "utf-8", split_console=True)
resave_file(tra_file, src_encoding, console_out_file, "utf-8")
else:
resave_file(tra_file, src_encoding, tra_out_file, dst_encoding)

Expand Down

0 comments on commit 2decc0e

Please sign in to comment.