Files
mediaproc/modelgen/generator/base.py
2026-02-06 20:18:45 -03:00

31 lines
762 B
Python

"""
Base Generator
Abstract base class for all code generators.
"""
from abc import ABC, abstractmethod
from pathlib import Path
from typing import Any, Dict
class BaseGenerator(ABC):
"""Abstract base for code generators."""
def __init__(self, name_map: Dict[str, str] = None):
self.name_map = name_map or {}
def map_name(self, name: str) -> str:
"""Apply name_map to a model name."""
return self.name_map.get(name, name)
@abstractmethod
def generate(self, models: Any, output_path: Path) -> None:
"""Generate code for the given models to the specified path."""
pass
@abstractmethod
def file_extension(self) -> str:
"""Return the file extension for this format."""
pass