INNER CODE UNIT · Python

_path_list_base_path

koxudaxi/datamodel-code-generator · src/datamodel_code_generator/__init__.py:377

def _path_list_base_path(input_paths: list[Path], caller_cwd: Path) -> Path:
    """Choose a list-input base without changing caller-relative module paths."""
    if all(path.is_relative_to(caller_cwd) for path in input_paths):
        return caller_cwd
    return Path(os.path.commonpath(path.parent for path in input_paths))


def _settings_path_from(base_path: Path, settings_path: Path | None) -> Path:
    """Resolve formatter settings from one explicit context root."""
    if settings_path is None:
        return base_path
    if settings_path.is_absolute():
        return settings_path
    return base_path / settings_path


def _output_context_path(output: Path | None, caller_cwd: Path) -> Path:
    """Return the directory observed by legacy output-context consumers."""

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…