Paper Office
paper-xlsxAPI referencepreserve.lifecycle

PartPlan

paper-xlsx 0.2.1 API reference

Adds/removals of whole parts for one save, with their content-type and relationship consequences planned in lockstep.

PartPlan(existing_names)

Attributes

added

attributeadded
= {}

ct_defaults

attributect_defaults
= []

ct_overrides

attributect_overrides
= []

ct_removals

attributect_removals
= []

dropped

attributedropped
= set()

existing

attributeexisting
= set(existing_names)

rel_appends

attributerel_appends
= {}

rel_removals

attributerel_removals
= {}

Functions

add_default

funcadd_default(extension, content_type)
paramextension
paramcontent_type

add_part

funcadd_part(name, payload, content_type=None, relate_from=None, rel_type=None, rel_id=None)

Plan a new part; returns the allocated relationship id (or rel_id when given). relate_from names the part whose rels must point at the new part (its rels part is created if absent — the saver resolves ids at apply time via resolve_rel_ids).

paramname
parampayload
paramcontent_type
= None
paramrelate_from
= None
paramrel_type
= None
paramrel_id
= None

apply_content_types

funcapply_content_types(payload)
parampayload

apply_rels

funcapply_rels(rels_part, payload)

The updated payload for one rels part (payload is None when the part does not exist yet — a fresh rels document is built).

paramrels_part
parampayload

remove_part

funcremove_part(name, referencing_rels=())

Plan a part's removal: dropped from the copy loop, its content-type override removed, and the named relationships cut. referencing_rels is [(rels_part, target_suffix)].

paramname
paramreferencing_rels
= ()

reserve_rid

funcreserve_rid(rels_part, existing_payload)

Sequential rId allocation shared by every planner touching one rels part (two independent next_rid computations collide).

paramrels_part
paramexisting_payload

touched_rels_parts

functouched_rels_parts()

On this page