Skip to content

pyflightstream.workspace.excel_file (stable)

Generated from the docstrings at build time: every one of the 6 names in the __all__ of pyflightstream.workspace.excel_file has an entry below. The names a guide or an example uses come first; the others follow under Advanced.

Explicit file transactions over the existing name-based synchronization engine.

Advanced

pyflightstream.workspace.excel_file.apply_batch

apply_batch(path: Path) -> dict

Apply one fresh preview, retaining exact originals and partial-write details.

Parameters:

Name Type Description Default
path Path

The preview batch file :func:preview_file wrote.

required

Returns:

Type Description
dict

The files written, their backups, the workbook's backup and the error of a partial write, if any.

Raises:

Type Description
ExcelSyncError

If the workbook, the matrices or the preview changed after the preview, or the preview holds INVALID or CONFLICT rows. A workbook that changes during the apply is not raised: the returned error names it and the original is kept.

pyflightstream.workspace.excel_file.cancel_batch

cancel_batch(path: Path) -> None

Mark a pending preview cancelled; never modify the workbook or matrices.

Parameters:

Name Type Description Default
path Path

The preview batch file :func:preview_file wrote.

required

Raises:

Type Description
ExcelSyncError

If the preview is not pending: already cancelled (said so), applied or invalid.

pyflightstream.workspace.excel_file.check_file

check_file(path: Path) -> None

Validate saved workbook identity and Dictionary mappings.

Parameters:

Name Type Description Default
path Path

The saved macro-free .xlsx workbook.

required

pyflightstream.workspace.excel_file.patch_cells

patch_cells(
    path: Path,
    changes: dict[str, dict[tuple[int, int], str]],
) -> None

Apply explicit literal cell edits, preserving all unrelated package members.

Parameters:

Name Type Description Default
path Path

The saved macro-free .xlsx workbook.

required
changes dict of str to dict of (int, int) to str

Worksheet name to the cells to set, (row, column) to literal text.

required

pyflightstream.workspace.excel_file.preview_file

preview_file(
    path: Path,
    *,
    workspace: Path,
    direction: Literal["read", "write"],
    batch: Path,
    matrices: list[str] | None = None,
) -> Path

Save a reviewable transaction and HTML preview without changing either input.

Parameters:

Name Type Description Default
path Path

The saved macro-free .xlsx workbook.

required
workspace Path

The workspace whose matrices are compared.

required
direction str

read (matrices to workbook) or write (workbook to matrices).

required
batch Path

A new preview batch file; an existing one is refused.

required
matrices list of str

The matrix files to compare. None compares every matrix of the workspace when reading, and the matrices the Runs rows name when writing.

None

Returns:

Type Description
Path

The HTML preview written beside the batch.

Raises:

Type Description
ExcelSyncError

If the workbook is not a .xlsx file, or the batch or its HTML preview already exists.

pyflightstream.workspace.excel_file.read_snapshot

read_snapshot(path: str | Path) -> WorkbookSnapshot

Read saved values and formula text without recalculating or opening Excel.

Parameters:

Name Type Description Default
path str or Path

The saved .xlsx workbook.

required

Returns:

Type Description
WorkbookSnapshot

The Runs headers and rows, the Dictionary entries and the baseline values.

Raises:

Type Description
ExcelSyncError

If the workbook lacks its Runs, Dictionary or _Baseline worksheet, or a header or Dictionary mapping is not unique literal text.