Browse Source

Add utility to clean the godot editor state

This is going to make git 100 times easier
master
Luna 7 years ago
parent
commit
0523776365
1 changed files with 23 additions and 0 deletions
  1. +23
    -0
      util/clear_editor_state.py

+ 23
- 0
util/clear_editor_state.py View File

@ -0,0 +1,23 @@
#!/usr/bin/python3
from pathlib import Path
# Current working directory
cwd = Path.cwd()
for path in cwd.glob('**/*.tscn'):
result = []
with path.open() as f:
for line in f.readlines():
if line.startswith('_sections_unfolded'):
# Skip lines that start with _sections_unfolded
continue
elif line.startswith('[node') and 'parent=' not in line:
# Root node, remove 'index="0"'
result.append(line.replace(' index="0"', ''))
else:
# Add line as is
result.append(line)
with path.open('w') as f:
f.writelines(result)

Loading…
Cancel
Save