mirror of
https://github.com/zeldaret/oot.git
synced 2025-05-10 02:54:24 +00:00
format.py: Allow empty files (#2434)
This commit is contained in:
parent
11b7bf2914
commit
5346c978a9
1 changed files with 2 additions and 3 deletions
|
@ -97,8 +97,7 @@ def run_clang_apply_replacements(tmp_dir: str):
|
||||||
|
|
||||||
def cleanup_whitespace(file: str):
|
def cleanup_whitespace(file: str):
|
||||||
"""
|
"""
|
||||||
Remove whitespace at the end of lines,
|
Remove whitespace at the end of lines, and ensure all lines end with a newline.
|
||||||
ensure the file ends with an empty line.
|
|
||||||
"""
|
"""
|
||||||
file_p = Path(file)
|
file_p = Path(file)
|
||||||
contents = file_p.read_text(encoding="UTF-8")
|
contents = file_p.read_text(encoding="UTF-8")
|
||||||
|
@ -108,7 +107,7 @@ def cleanup_whitespace(file: str):
|
||||||
if n_subst != 0:
|
if n_subst != 0:
|
||||||
modified = True
|
modified = True
|
||||||
|
|
||||||
if not contents.endswith("\n"):
|
if contents and not contents.endswith("\n"):
|
||||||
contents += "\n"
|
contents += "\n"
|
||||||
modified = True
|
modified = True
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue