Skip to content

Commit 5942ef5

Browse files
committed
fix tester
1 parent d435d7d commit 5942ef5

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

spine_tester/create_tester.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,33 @@ def find_spinescene_files():
138138

139139
print(f"Lua table with animations has been written to {lua_output_file_path}")
140140

141+
import configparser
142+
import os
143+
144+
class CustomConfigParser(configparser.ConfigParser):
145+
"""Custom ConfigParser to add spaces around '=' when writing."""
146+
def write(self, fp, space_around_delimiters=True):
147+
"""Write an .ini-format representation of the configuration state."""
148+
if space_around_delimiters:
149+
delimiter = " = "
150+
else:
151+
delimiter = "="
152+
153+
for section in self._sections:
154+
fp.write(f"[{section}]\n")
155+
for key, value in self._sections[section].items():
156+
if value is not None:
157+
value = str(value).replace("\n", "\n\t")
158+
fp.write(f"{key}{delimiter}{value}\n")
159+
fp.write("\n")
160+
141161
def modify_game_project(file_path):
142162
if not os.path.isfile(file_path):
143163
print(f"Error: The file '{file_path}' does not exist.")
144164
return
145165

146166
# Load the existing game.project file
147-
config = configparser.ConfigParser(allow_no_value=True, delimiters=('='))
167+
config = CustomConfigParser(allow_no_value=True, delimiters=('='))
148168
config.optionxform = str # Preserve case sensitivity
149169
config.read(file_path)
150170

@@ -172,9 +192,9 @@ def modify_game_project(file_path):
172192
config["spine"] = {}
173193
config["spine"]["max_count"] = "8192"
174194

175-
# Save the updated file
195+
# Save the updated file with spaces around the '='
176196
with open(file_path, "w") as configfile:
177-
config.write(configfile, space_around_delimiters=False)
197+
config.write(configfile, space_around_delimiters=True)
178198

179199
def delete_project_files():
180200
# Define file patterns to delete and track deleted file counts

0 commit comments

Comments
 (0)