config_loader.py 944 B

123456789101112131415161718192021222324
  1. import yaml
  2. from pathlib import Path
  3. class ConfigLoader:
  4. def __init__(self, config_path="config/cell_config.yaml"):
  5. self.config_path = Path(__file__).parent / config_path
  6. with open(self.config_path, 'r') as f:
  7. self.config = yaml.safe_load(f)
  8. def get_cell_ids_for_subsegment(self, segment_id, subsegment_id):
  9. """Get cell IDs for a specific subsegment"""
  10. for segment in self.config['segments']:
  11. if segment['id'] == segment_id:
  12. for subsegment in segment['subsegments']:
  13. if subsegment['id'] == subsegment_id:
  14. return subsegment['cell_ids'] # Updated key name
  15. return []
  16. def get_segment_config(self, segment_id):
  17. """Get configuration for a specific segment"""
  18. for segment in self.config['segments']:
  19. if segment['id'] == segment_id:
  20. return segment
  21. return None