Skip to content

Commit

Permalink
add cleanup options
Browse files Browse the repository at this point in the history
  • Loading branch information
AGulev committed Dec 10, 2024
1 parent 5b92e4a commit 339fddb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
6 changes: 6 additions & 0 deletions spine_tester/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

>python ./spine_tester/create_tester.py
It's also possible to remove all the `*.go`, `*.gui`, `*.collection` and `hooks.editor_script` files if it runs with `cleanup` argument:

>python ./spine_tester/create_tester.py cleanup
It maybe useful in cases you want to run the editor faster on a big project.

3. If project is already opened click: `Project`->`Fetch Libraries` or open project

4. Run the project and use the interface to play any animations you want, or all of them one by one.
Expand Down
29 changes: 28 additions & 1 deletion spine_tester/create_tester.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import json

import glob
import os
import subprocess
import sys
Expand Down Expand Up @@ -176,8 +176,35 @@ def modify_game_project(file_path):
with open(file_path, "w") as configfile:
config.write(configfile, space_around_delimiters=False)

def delete_project_files(parent_folder):
if not os.path.isdir(parent_folder):
print(f"Error: The folder '{parent_folder}' does not exist.")
return

# Define file patterns to delete and track deleted file counts
file_patterns = ["*.collection", "*.go", "*.gui", "hooks.editor_script"]
deleted_counts = {pattern: 0 for pattern in file_patterns}

# Loop through patterns and delete matching files
for pattern in file_patterns:
for file_path in glob.glob(os.path.join(parent_folder, "**", pattern), recursive=True):
try:
os.remove(file_path)
deleted_counts[pattern] += 1
except Exception as e:
print(f"Error deleting {file_path}: {e}")

# Log the counts of deleted files
for pattern, count in deleted_counts.items():
print(f"{pattern}: {count} files deleted")

# Run the function
if __name__ == "__main__":
# Check if the first argument is "cleanup"
if len(sys.argv) > 1 and sys.argv[1].lower() == "cleanup":
# Determine parent folder where game.project resides
parent_folder = os.path.abspath(os.path.join(".."))
delete_project_files(parent_folder)
# Path to the game.project file in the parent folder
game_project_path = os.path.join("..", "game.project")
modify_game_project(game_project_path)
Expand Down

0 comments on commit 339fddb

Please sign in to comment.