cadrumo.adapters.outbound.google._calc_sheets_apply_values module¶
Google Sheets value-write payload builders for calc sheet exports.
adapters.outbound.google.calc_sheets_apply clears the workbook
tabs and passes these payloads to the shared
adapters.outbound.google.api.execute_request() boundary for a
Sheets values.batchUpdate call. This module stays pure: it maps
application.storage.calc_sheets.records.SheetExportPlan facets into A1
ranges plus row values and never opens a Google service object itself.
See also
build_value_data() and build_formula_data() emit the main
workbook grid, while build_evidence_value_data() mirrors
application.storage.calc_sheets.export_tables.evidence_table() so the online
Evidencia tab is derived from the live export plan.
- coerce_cell_value(value)[source]¶
Convert a
application.storage.calc_sheets.records.SheetValueCellvalue.Nonebecomes an empty cell, booleans stay native, andDecimalvalues are rendered with fixed-point text so Sheets does not receive rounded binary floats.
- build_value_data(value_cells)[source]¶
Build
values.batchUpdateentries forapplication.storage.calc_sheets.records.SheetValueCell.- Return type:
list[ValueRange]
- Parameters:
value_cells (Iterable[SheetValueCell])
- build_formula_data(formula_cells)[source]¶
Build entries for
application.storage.calc_sheets.records.SheetFormulaCellrecords.Formula text is prefixed with
=becauseapplication.storage.calc_sheetsstores formula bodies without the leading Sheets marker.- Return type:
list[ValueRange]
- Parameters:
formula_cells (Iterable[SheetFormulaCell])
- build_row_set_header_data(row_sets)[source]¶
Emit Detalle-tab header cells for
application.storage.calc_sheets.records.SheetRowSet.- Return type:
list[ValueRange]
- Parameters:
row_sets (Iterable[SheetRowSet])
- build_evidence_value_data(plan)[source]¶
Build Evidencia-tab value writes for
plan.Uses
application.storage.calc_sheets.export_tables.evidence_table(), the same source owned by the live export-plan boundary.- Return type:
list[ValueRange]
- Parameters:
plan (SheetExportPlan)
- build_guide_value_data(plan)[source]¶
Build Guide-tab title, paragraph, and export-stamp rows for
plan.- Return type:
list[ValueRange]
- Parameters:
plan (SheetExportPlan)
- payload_written_addresses(data)[source]¶
Return every qualified A1 address a
values.batchUpdatepayload writes.This is deliberately derived from the PAYLOAD rather than re-walked from the plan. Re-deriving the extent from the plan would be a second implementation of the layout the builders above already encode, and the two would drift — the stale-cell set would then name cells the write actually covered, and clearing them would blank live content.
- written_cell_values(data)[source]¶
Return every qualified address a payload writes, mapped to its target value.
Companion to
payload_written_addresses(), sharing the same walk so the address set and the value map cannot drift against each other. Values are the entry’s raw cell content — the same shapecoerce_cell_value()already produced for a real write — never re-derived from the plan. This is what an export preview diffs against a read-back of current content to answer “would this cell’s value change”.
- stale_addresses(*, occupied, written)[source]¶
Return the addresses a previous run filled that this write does not replace.
The whole point of the clear step: a re-apply must not leave a longer previous run’s trailing cells standing beside the new content. Only those cells are named — never a cell the write covers, and never a cell that was already empty — so a clear can no longer blank content the workbook is not about to receive.
Sorted so the emitted request is deterministic and diffable.
- changed_cell_addresses(*, target, current)[source]¶
Return the addresses in
targetwhose value would actually change.targetiswritten_cell_values()for the non-formula value payload;currentis a read-back of the same addresses’ present content. An address absent fromcurrentreads as blank, matching how a value cell’s coerced blank ("") compares against nothing having been read there before. Both sides are normalised throughcoerce_decimal()where possible so a Decimal written as fixed-point text ("1234.50") is compared against the number Sheets already stores (1234.5) rather than failing every numeric cell on string shape alone.Sorted so the result is deterministic and diffable, matching
stale_addresses().