Files
SnarfCode/scripts/fix_homepage_icons.py

43 lines
1.7 KiB
Python

import yaml
def str_presenter(dumper, data):
if '\n' in data:
return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|')
return dumper.represent_scalar('tag:yaml.org,2002:str', data)
yaml.add_representer(str, str_presenter)
yaml.representer.SafeRepresenter.add_representer(str, str_presenter)
with open('homelab-gitops-repo/manifests/spaceport/homepage/homepage.yaml', 'r', encoding='utf-8') as f:
text = f.read()
docs = list(yaml.safe_load_all(text))
cm = docs[2]
services = yaml.safe_load(cm['data']['services.yaml'])
for group in services:
# 1. Fix ArgoCD icon in GitOps & Automation
if 'GitOps & Automation' in group:
for item in group['GitOps & Automation']:
if 'ArgoCD' in item:
print("Updating ArgoCD icon from:", item['ArgoCD'].get('icon'))
item['ArgoCD']['icon'] = 'argo-cd.png'
print("To:", item['ArgoCD']['icon'])
# 2. Fix Tempest Weather Station icon in Environment & Weather
if 'Environment & Weather' in group:
for item in group['Environment & Weather']:
if 'Tempest Weather Station' in item:
print("Updating Tempest icon from:", item['Tempest Weather Station'].get('icon'))
item['Tempest Weather Station']['icon'] = 'mdi-weather-partly-cloudy'
print("To:", item['Tempest Weather Station']['icon'])
cm['data']['services.yaml'] = yaml.dump(services, sort_keys=False, default_flow_style=False, allow_unicode=True)
with open('homelab-gitops-repo/manifests/spaceport/homepage/homepage.yaml', 'w', encoding='utf-8') as f:
yaml.dump_all(docs, f, sort_keys=False, default_flow_style=False, allow_unicode=True)
print("\nSuccessfully updated homepage.yaml with corrected icons!")