import logging logger = logging.getLogger(__name__) def get_sources(path, delimiter='\n'): """Load source URLs from a file, one per line. Blank lines and lines starting with ``#`` are ignored, so the file can be annotated with comments (e.g. grouping HTML vs. RSS feeds). """ logger.info("Attempting to load sources from file: '%s' with delimiter: %r", path, delimiter) try: with open(path, 'r', encoding='utf-8-sig') as source_file: content = source_file.read() except FileNotFoundError: logger.error("Source file not found at path: '%s'", path, exc_info=True) raise except PermissionError: logger.error("Permission denied when accessing source file: '%s'", path, exc_info=True) raise except Exception as e: logger.error("Failed to read sources from '%s': %s", path, e, exc_info=True) raise sources = [] for line in content.split(delimiter): stripped = line.strip() if not stripped or stripped.startswith('#'): continue sources.append(stripped) logger.info("Successfully loaded %d source entries from '%s'", len(sources), path) return sources