245 lines
6.3 KiB
Python
Executable File
245 lines
6.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
🎨 FOLDER STATUS AUTO-UPDATER
|
|
Automatically updates README.md status indicators based on folder contents!
|
|
|
|
Usage: python update_folder_status.py
|
|
"""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
# Base path
|
|
BASE_PATH = Path(__file__).parent / "tiled"
|
|
|
|
# Folder configurations
|
|
FOLDERS = {
|
|
"maps": {
|
|
"extensions": [".tmx", ".json"],
|
|
"description": "Vse .tmx in .json Tiled map files"
|
|
},
|
|
"tilesets": {
|
|
"extensions": [".tsx"],
|
|
"description": "Vse .tsx tileset files"
|
|
},
|
|
"tutorials": {
|
|
"extensions": [".md"],
|
|
"description": "Vsi Tiled vodiči in navodila"
|
|
},
|
|
"TODO": {
|
|
"extensions": [".md"],
|
|
"description": "Kaj je še treba narediti za Tiled"
|
|
}
|
|
}
|
|
|
|
def count_files(folder_path, extensions):
|
|
"""Count files with specific extensions in folder"""
|
|
count = 0
|
|
if folder_path.exists():
|
|
for ext in extensions:
|
|
count += len(list(folder_path.glob(f"*{ext}")))
|
|
return count
|
|
|
|
def get_status_icon(file_count, folder_name):
|
|
"""Determine status icon based on file count"""
|
|
if file_count == 0:
|
|
return "🔴", "PRAZNO"
|
|
elif folder_name == "TODO" or file_count < 5: # TODO is always in progress
|
|
return "🟣", "V DELU"
|
|
else:
|
|
return "🟢", "DOKONČANO"
|
|
|
|
def generate_readme(folder_name, config):
|
|
"""Generate README.md content for folder"""
|
|
folder_path = BASE_PATH / folder_name
|
|
file_count = count_files(folder_path, config["extensions"])
|
|
icon, status = get_status_icon(file_count, folder_name)
|
|
|
|
# Generate content
|
|
content = f"""# {icon} {folder_name.upper()} FOLDER - {status}
|
|
|
|
**Status:** {icon} **{status}** ({file_count} files)
|
|
|
|
---
|
|
|
|
## 📁 **KAJ PRIDE SEM:**
|
|
|
|
```
|
|
{config['description']}
|
|
```
|
|
|
|
---
|
|
|
|
## 📊 **TRENUTNI STATUS:**
|
|
|
|
"""
|
|
|
|
if file_count == 0:
|
|
content += """Mapa je **PRAZNA**.
|
|
|
|
---
|
|
|
|
## 🚀 **NEXT:**
|
|
|
|
Ko boš dodajal files sem, status se avtomatsko posodobi:
|
|
- 🔴 → 🟣 (če začneš dodajat)
|
|
- 🟣 → 🟢 (ko končaš!)
|
|
|
|
Run: `python update_folder_status.py` za update!
|
|
"""
|
|
else:
|
|
content += f"""Mapa ima **{file_count} files**!
|
|
|
|
"""
|
|
# List files
|
|
if folder_path.exists():
|
|
files = []
|
|
for ext in config["extensions"]:
|
|
files.extend(folder_path.glob(f"*{ext}"))
|
|
|
|
if files:
|
|
content += "**Files:**\n```\n"
|
|
for f in sorted(files)[:10]: # Show first 10
|
|
content += f"✅ {f.name}\n"
|
|
if len(files) > 10:
|
|
content += f"... and {len(files) - 10} more!\n"
|
|
content += "```\n\n"
|
|
|
|
content += """---
|
|
|
|
## 🔄 **POSODABLJANJE:**
|
|
|
|
Status se avtomatsko posodobi glede na število files!
|
|
|
|
Run: `python update_folder_status.py` za refresh!
|
|
"""
|
|
|
|
content += """
|
|
---
|
|
|
|
**Check: `/tiled/STATUS.md` za overview!**
|
|
"""
|
|
|
|
return content
|
|
|
|
def update_all_folders():
|
|
"""Update README.md in all folders"""
|
|
print("🎨 UPDATING FOLDER STATUS INDICATORS...\n")
|
|
|
|
for folder_name, config in FOLDERS.items():
|
|
folder_path = BASE_PATH / folder_name
|
|
readme_path = folder_path / "README.md"
|
|
|
|
# Generate new content
|
|
content = generate_readme(folder_name, config)
|
|
|
|
# Write to file
|
|
try:
|
|
readme_path.parent.mkdir(parents=True, exist_ok=True)
|
|
readme_path.write_text(content, encoding='utf-8')
|
|
|
|
# Get status for display
|
|
file_count = count_files(folder_path, config["extensions"])
|
|
icon, status = get_status_icon(file_count, folder_name)
|
|
|
|
print(f"{icon} {folder_name:12} → {status:12} ({file_count} files) ✅")
|
|
except Exception as e:
|
|
print(f"❌ Error updating {folder_name}: {e}")
|
|
|
|
print("\n✅ ALL FOLDERS UPDATED!")
|
|
print("\n📊 Summary saved to: tiled/STATUS.md")
|
|
|
|
# Update main STATUS.md
|
|
update_status_overview()
|
|
|
|
def update_status_overview():
|
|
"""Update main STATUS.md file"""
|
|
status_content = """# 📊 TILED FOLDER STATUS OVERVIEW
|
|
|
|
**Last Updated:** {timestamp}
|
|
**Auto-generated by:** update_folder_status.py
|
|
|
|
---
|
|
|
|
## 📂 **FOLDER STATUS:**
|
|
|
|
```
|
|
/tiled/
|
|
"""
|
|
|
|
from datetime import datetime
|
|
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
|
|
total_complete = 0
|
|
total_in_progress = 0
|
|
total_empty = 0
|
|
total_files = 0
|
|
|
|
for folder_name, config in FOLDERS.items():
|
|
folder_path = BASE_PATH / folder_name
|
|
file_count = count_files(folder_path, config["extensions"])
|
|
icon, status = get_status_icon(file_count, folder_name)
|
|
|
|
status_content += f"├── {icon} {folder_name:12} [{status:12} - {file_count} files]\n"
|
|
|
|
total_files += file_count
|
|
if status == "DOKONČANO":
|
|
total_complete += 1
|
|
elif status == "V DELU":
|
|
total_in_progress += 1
|
|
else:
|
|
total_empty += 1
|
|
|
|
status_content += """```
|
|
|
|
---
|
|
|
|
## 🎯 **STATUS LEGENDA:**
|
|
|
|
| Pike | Status | Opis |
|
|
|------|--------|------|
|
|
| 🟢 | **DOKONČANO** | Folder je complete, ready to use! |
|
|
| 🟣 | **V DELU** | Nekaj je notri, še ni končano |
|
|
| 🔴 | **PRAZNO** | Nič ni notri, čaka na content |
|
|
|
|
---
|
|
|
|
## 📊 **STATISTICS:**
|
|
|
|
```
|
|
TOTAL FOLDERS: {total}
|
|
├── 🟢 Complete: {complete} ({complete_pct}%)
|
|
├── 🟣 In Progress: {progress} ({progress_pct}%)
|
|
└── 🔴 Empty: {empty} ({empty_pct}%)
|
|
|
|
TOTAL FILES: {files}
|
|
```
|
|
|
|
---
|
|
|
|
## 🔄 **AUTO-UPDATE:**
|
|
|
|
Run `python update_folder_status.py` to refresh all status indicators!
|
|
|
|
---
|
|
|
|
**When folder is done → Status changes automatically! 🔴 → 🟣 → 🟢**
|
|
""".format(
|
|
timestamp=timestamp,
|
|
total=len(FOLDERS),
|
|
complete=total_complete,
|
|
progress=total_in_progress,
|
|
empty=total_empty,
|
|
complete_pct=round(total_complete/len(FOLDERS)*100),
|
|
progress_pct=round(total_in_progress/len(FOLDERS)*100),
|
|
empty_pct=round(total_empty/len(FOLDERS)*100),
|
|
files=total_files
|
|
)
|
|
|
|
status_path = BASE_PATH / "STATUS.md"
|
|
status_path.write_text(status_content, encoding='utf-8')
|
|
print(f"✅ STATUS.md updated! ({total_files} total files)")
|
|
|
|
if __name__ == "__main__":
|
|
update_all_folders()
|