qecx.dump_qecx

qecx.dump_qecx(document, target, *, layout='preserve', auto_threshold_bytes=_AUTO_THRESHOLD_BYTES, force_archive=False, validate=True)

Write a QECX document to a path or binary stream.

With validate=True, completeness plus the full rule engine run before writing: error findings raise, and each warning finding is emitted as a Python warning. validate=False writes the document without validation, e.g. for persisting a known-invalid document while debugging.

The written document carries the format version from CURRENT_QECX_VERSION, as QECXDocument.to_dict() does. When the document’s properties set no creator, writing stamps a creator from qecx_creator(), independently of validate; document itself is never modified, the stamp appears in the written form only. Loading the written file yields a document equal to document: parametric references are written in their raw reference form, and untouched loaded fragments re-save byte for byte through their carried source text.

QECXDocument.save() and QECXDocument.dumps() are the document’s own forms of this function.

Parameters:
  • document (QECXDocument) – The document to write.

  • target (str | Path | BinaryIO | BufferedIOBase) – Destination path, or a writable binary stream such as an open file or an io.BytesIO; an existing file is overwritten.

  • layout (Literal["preserve", "inline", "auto", "external"]) – Where the document’s externalizable payloads go, as in QECXDocument.save(): "preserve" keeps each payload where it sat, "inline" writes every payload into the document, "auto" externalizes the payloads above the threshold, and "external" externalizes every non-empty payload. A payload with no content never becomes a member. The envelope follows the outcome: a ZIP archive when at least one payload becomes a member, inline JSON text otherwise.

  • auto_threshold_bytes (int) – Payload size from which an automatic decision externalizes, in bytes of the serialized payload.

  • force_archive (bool) – Write the ZIP envelope even when no payload becomes a member, layout="inline" included.

  • validate (bool) – Validate the document before writing.

Raises:

QECXValidationFailedError – If validate=True and the document is incomplete, or validation produced one or more error-severity findings; the completeness findings match those QECXDocument.missing() returns.