""" Scientific Gallery Generator - Legacy CLI Entry Point This module provides backward compatibility for the legacy CLI interface. For new development, use the gallery package API directly: from gallery import generate, GalleryConfig config = GalleryConfig.from_yaml("config.yaml") generate(config, verbose=True) Or use the new CLI: gallery --config config.yaml --verbose """ from gallery import generate from gallery.config import GalleryConfig def main(clean_first: bool = False, source_override: str = None) -> None: """ Main entry point for gallery generation (legacy interface). Args: clean_first: If True, removes and recreates the gallery directory source_override: If provided, only process this source directory. If not in config, it will be temporarily added. Processes all configured sources and generates the complete gallery structure in the web directory. Ensures assets are available. """ try: # Load configuration from config.yaml config = GalleryConfig.from_yaml("config.yaml") # Handle source override if source_override: from pathlib import Path from gallery.config import GallerySource source_path = Path(source_override).resolve() # Check if source is in config matching_source = None for source in config.sources: if Path(source.path).resolve() == source_path: matching_source = source break # If not in config, create a temporary source entry if matching_source is None: source_name = source_path.name print( f"Source {source_override} not in config. " f"Adding temporarily as '{source_name}'" ) config.sources = [ GallerySource(name=source_name, path=source_path) ] else: config.sources = [matching_source] # Generate gallery using the new API success = generate( config=config, clean_first=clean_first, verbose=True ) if not success: exit(1) except Exception as e: print(f"Error: {e}") exit(1) if __name__ == "__main__": import argparse parser = argparse.ArgumentParser(description='Generate gallery') parser.add_argument( '--clean', action='store_true', help='Clean gallery directory before generation' ) parser.add_argument( '--source', type=str, default=None, help='Override to only recompute a specific source directory. ' 'If the directory is not in config, it will be added temporarily.' ) args = parser.parse_args() main(clean_first=args.clean, source_override=args.source)