39 lines
1.0 KiB
Python
39 lines
1.0 KiB
Python
#!/usr/bin/env python3
|
|
# Sunday Comics - Cache rebuild script
|
|
# Copyright (c) 2025 Tomasita Cabrera
|
|
# Licensed under the MIT License - see LICENSE file for details
|
|
|
|
"""
|
|
Script to rebuild the comics cache from YAML files.
|
|
Useful for forcing a fresh cache build.
|
|
"""
|
|
import sys
|
|
import os
|
|
|
|
# Add parent directory to path so we can import data_loader
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
from data_loader import load_comics_from_yaml, clear_cache
|
|
|
|
|
|
def main():
|
|
"""Rebuild the comics cache"""
|
|
print("Clearing existing cache...")
|
|
clear_cache()
|
|
print()
|
|
|
|
print("Rebuilding cache from YAML files...")
|
|
# Load with cache enabled - since we just cleared it, this will reload from YAML
|
|
# and automatically save the cache
|
|
comics = load_comics_from_yaml(use_cache=True)
|
|
print()
|
|
|
|
if comics:
|
|
print(f"✓ Cache rebuilt successfully with {len(comics)} comics")
|
|
else:
|
|
print("✗ No comics found to cache")
|
|
sys.exit(1)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|