Initial commit
This commit is contained in:
50
update_nails.py
Normal file
50
update_nails.py
Normal file
@@ -0,0 +1,50 @@
|
||||
import json
|
||||
import os
|
||||
|
||||
characters_dir = 'nodes/character_reader/characters'
|
||||
|
||||
print(f"Looking for characters in: {os.path.abspath(characters_dir)}")
|
||||
|
||||
if not os.path.exists(characters_dir):
|
||||
print(f"ERROR: Directory {characters_dir} does not exist.")
|
||||
exit(1)
|
||||
|
||||
files = [f for f in os.listdir(characters_dir) if f.endswith('.json')]
|
||||
print(f"Found {len(files)} JSON files.")
|
||||
|
||||
for filename in files:
|
||||
filepath = os.path.join(characters_dir, filename)
|
||||
print(f"Processing {filename}...")
|
||||
|
||||
try:
|
||||
with open(filepath, 'r') as f:
|
||||
data = json.load(f)
|
||||
except Exception as e:
|
||||
print(f" Error reading {filename}: {e}")
|
||||
continue
|
||||
|
||||
primary_color = data.get('styles', {}).get('primary_color')
|
||||
|
||||
if primary_color:
|
||||
if 'identity' not in data:
|
||||
data['identity'] = {}
|
||||
|
||||
hands = data['identity'].get('hands', '')
|
||||
nail_string = f"{primary_color} nails"
|
||||
|
||||
# Check if nails are already mentioned
|
||||
if "nails" not in hands and "polish" not in hands:
|
||||
if hands and hands.strip():
|
||||
new_hands = f"{hands}, {nail_string}"
|
||||
else:
|
||||
new_hands = nail_string
|
||||
|
||||
data['identity']['hands'] = new_hands
|
||||
print(f" UPDATING: '{hands}' -> '{new_hands}'")
|
||||
|
||||
with open(filepath, 'w') as f:
|
||||
json.dump(data, f, indent=2)
|
||||
else:
|
||||
print(f" Skipping: Nails already present ('{hands}')")
|
||||
else:
|
||||
print(f" Skipping: No primary color found.")
|
||||
Reference in New Issue
Block a user