from typing import Dict, List import logging import json from pathlib import Path logger = logging.getLogger(__name__) class GrowingGuideManager: def __init__(self): self.guides = [] def load_guides(self, guides_path: Path) -> List[Dict]: """Load guides from the data directory""" guides = [] if guides_path.exists(): logger.info(f"Loading guides from {guides_path}") for guide_file in guides_path.glob("*.json"): try: logger.info(f"Processing guide file: {guide_file}") with open(guide_file, 'r', encoding='utf-8') as f: guide_data = json.load(f) guides.append(guide_data) logger.info(f"Successfully loaded guide for: {guide_data.get('strain_name')}") except Exception as e: logger.error(f"Error loading guide {guide_file}: {str(e)}") else: logger.warning(f"Guides path does not exist: {guides_path}") self.guides = guides return guides def get_guide_by_strain(self, strain_name: str) -> Dict: """Get a specific guide by strain name""" for guide in self.guides: if guide.get('strain_name', '').lower() == strain_name.lower(): return guide return None def get_all_guides(self) -> List[Dict]: """Get all loaded guides""" return self.guides