call_report.fca.transport.LocalDirectoryTransport#

class call_report.fca.transport.LocalDirectoryTransport(*, data_dir: ~pathlib.Path, dirname_for: ~collections.abc.Callable[[~call_report.core._periods.ReportingPeriod], str] = <function _default_dirname>)[source]#

Bases: object

A transport that resolves periods to pre-extracted local directories.

Expects data_dir to contain one subdirectory per period, each holding that period’s already-downloaded and unzipped FCA release files.

Attributes:
data_dirpathlib.Path

The parent directory containing one subdirectory per period.

dirname_forCallable[[ReportingPeriod], str]

Return the default per-period directory name: the FCA zip’s stem.

Examples

>>> with tempfile.TemporaryDirectory() as tmp:
...     data_dir = Path(tmp)
...     (data_dir / "2026March").mkdir()
...     transport = LocalDirectoryTransport(data_dir=data_dir)
...     resolved = transport.resolve(
...         period=ReportingPeriod.from_period_end(value="2026-03-31")
...     )
...     resolved.name
'2026March'
dirname_for() str[source]#

Return the default per-period directory name: the FCA zip’s stem.

Matches the name produced by downloading and unzipping FCA’s own archive for that period.

Parameters:
periodReportingPeriod

The period to name a directory for.

Returns:
str

The FCA download URL’s filename without its .zip extension, e.g. "2026March" or "Mar2003".

resolve(*, period: ReportingPeriod) Path[source]#

Return period’s subdirectory under data_dir.

Implements the FCATransport protocol for pre-extracted local data.

Parameters:
periodReportingPeriod

The period to resolve.

Returns:
pathlib.Path

The resolved, existing directory.

Raises:
DownloadError

If no directory exists at the expected location.