Coverage for domain / adapters / file_factories.py: 100.00%
6 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-07 00:07 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-07 00:07 +0000
1from controller.path_protocol import PathLike
2from domain.model.file import File
5def file_from_path(path: PathLike) -> File:
6 """Construct a domain `File` from a Path-like object.
8 This function expects a Path-like object that provides `.name` and
9 `.stat().st_size` (for example a `pathlib.Path` or a test mock that
10 implements the `PathLike` protocol defined in `controller.path_protocol`).
11 """
12 p = path
13 size = p.stat().st_size
14 return File(name=p.name, size_bytes=size)