Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 25 additions & 24 deletions tools/update_pre_commit_excluded_addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,32 @@ def update_not_installable_addons_dir_in_file(
line_format.format(addon_dir=addon_dir)
for addon_dir in not_installable_addons_dir
]
if not_installable_addons_dir:
with open(file_path, "r+") as text_io:
lines = text_io.readlines()
text_io.seek(0)
replace_on = False
for line in lines:
if PRE_COMMIT_EXCLUDE_SEPARATOR_END in line:
replace_on = False
if replace_on:
continue
if PRE_COMMIT_EXCLUDE_SEPARATOR in line:
replace_on = True
text_io.write(line)
preprend_spaces = line[: len(line) - len(line.lstrip(" "))]
content_to_replace = line_end.join(
[
f"{preprend_spaces}{addon_dir}"
for addon_dir in not_installable_addons_dir
]
)
content_to_replace += line_end
text_io.write(content_to_replace)
continue
with open(file_path, "r+") as text_io:
lines = text_io.readlines()
text_io.seek(0)
replace_on = False
for line in lines:
if PRE_COMMIT_EXCLUDE_SEPARATOR_END in line:
replace_on = False
if replace_on:
continue
if PRE_COMMIT_EXCLUDE_SEPARATOR in line:
replace_on = True
text_io.write(line)
text_io.truncate()
preprend_spaces = line[: len(line) - len(line.lstrip(" "))]
content_to_replace = line_end.join(
[
f"{preprend_spaces}{addon_dir}"
for addon_dir in not_installable_addons_dir
]
)
if not content_to_replace:
continue
content_to_replace += line_end
text_io.write(content_to_replace)
continue
text_io.write(line)
text_io.truncate()


@click.command()
Expand Down