Write icon entries to manifest only if changed

This commit is contained in:
Serhii Snitsaruk 2024-08-07 17:47:50 +02:00
parent 629062ea26
commit 304bd86220
No known key found for this signature in database
GPG Key ID: A965EF8799FFEC2D
1 changed files with 15 additions and 11 deletions

View File

@ -32,15 +32,16 @@ def update_icon_entries(silent=False):
config_dir = get_script_dir()
config_path = os.path.join(config_dir, "limboai.gdextension")
content = ""
new_content = ""
f = open(config_path, "r")
for line in f:
if line.startswith("[icons]"):
break
content += line
f.close()
content += "[icons]\n\n"
index = content.find("[icons]")
new_content = content[0:index]
new_content += "[icons]\n\n"
icon_files = []
icons_dir = os.path.join(config_dir, "../icons/")
@ -50,15 +51,18 @@ def update_icon_entries(silent=False):
icon_files.sort()
for icon_file in icon_files:
content += os.path.splitext(icon_file)[0] + ' = "res://addons/limboai/icons/' + icon_file + '"\n'
new_content += os.path.splitext(icon_file)[0] + ' = "res://addons/limboai/icons/' + icon_file + '"\n'
if new_content != content:
f = open(config_path, "w")
f.write(content)
f.write(new_content)
f.close()
if not silent:
print(content)
print("======= Icon entries updated =======")
print(new_content)
print("=== Icon entries updated ===")
else:
if not silent:
print("=== No update needed for icon entries ===")
if __name__ == "__main__":