Skip to content

hertzforge.report.identity

identity

Identity and issue: which report, which revision, where it ends, and no silent reissue (report feature report_identity).

A page that cannot say which report and which revision it belongs to, or where the report ends, cannot be told apart from a page of another report, and a reader cannot tell a complete copy from a partial one. With the feature on, every printed page carries the laboratory, the report number and revision, the title and page n of N, and the first page carries the identification block: the laboratory's address, where the work was done, the customer and contact, the dates of receipt, test and issue, the people authorizing the report with a blank line for each signature, and the statement that the report is not reproduced except in full. The report closes with "End of report." (or "End of amendment.").

Every field is entered by the author (identify). The program never writes a report number, a revision, a date or a name of its own: a field not yet entered shows as not entered, and the report cannot be issued until each one the identification needs is there (missing).

A report is a draft until it is issued. Issuing it (report.issue) records the revision issued, with the SHA-256 of the issued document and of its content. From then on the report is not changed under that identity: an export whose content differs from what was issued is refused (guard), whatever changed, a block, a number or the data under a figure. A change after issue is an amendment (amend): its own revision, the report it amends by number, revision and date, and a table of what changed (where, what it said, what it now says, and why), which is then issued in turn. The original's record is kept.

The paginated issued form is a PDF printed from the same page (report.print); the page numbers are the print engine's own page counters, so page n of N is what the PDF holds.

Classes:

Name Description
Field

One identification field the author enters.

Functions:

Name Description
value

What the author entered for field key ('' or [] when nothing),

record

The issue record: one entry per revision issued, oldest first,

identify

Enter identification fields on report.

name

'Report R-0037, Revision 1': the identity every page carries,

missing

The labels of the fields the identification needs that are not

amendment

Which amendment the report is (1 for the first), or 0 when it is

end_mark

The report's last line: 'End of amendment.' for an amendment,

content_hash

The SHA-256 (hex) of a rendered page without its stamped blocks and

viewer_content_hash

The SHA-256 (hex) of the report a viewer page holds: its title,

guard

Refuse to write page (the report rendered for export) when the

issue_ready

Check that report can be issued now, and return the status it

settled

An identity read from a file: a status of issued or amended with no

mark_issued

Set the status issue_ready returned: around rendering the issued

unmark

Put back the identity mark_issued returned.

record_issue

Add the revision just issued to the issue record: its number,

amend

Make the issued report an amendment, to be issued in its turn.

status_words

The status as the page says it: 'Draft', 'Draft amendment',

block_html

The identification block for the first page, as HTML.

page_css

The printed page's margins for report: the laboratory and the

Classes

Field dataclass

Field(key: str, label: str, required: bool = True)

One identification field the author enters.

required fields must be entered before the report is issued.

Functions:

value

value(report: Any, key: str) -> Any

What the author entered for field key ('' or [] when nothing), or the report's status ('draft' until issued) or full_only (True until turned off).

record

record(report: Any) -> list[dict[str, Any]]

The issue record: one entry per revision issued, oldest first, each with its number, revision, status, date of issue, the SHA-256 of the issued PDF and of its content, the file written, and for an amendment the changes it made.

identify

identify(report: Any, **fields: Any) -> None

Enter identification fields on report.

Each keyword is a key of FIELDS, a string ('' clears it), except authorized, the people authorizing the report, one per entry or one per line ("name, role"), and full_only, whether the first page says the report is not reproduced except in full (True by default).

Refused before anything changes: an unknown field; the status, the amendment and the issue record, which change only by issuing and amending; a value of the wrong type; and the number or revision of a report that has been issued, which change only by an amendment.

Raises:

Type Description
ValueError

For a refusal; the message names the field and the reason.

TypeError

When a value is of the wrong type.

name

name(report: Any) -> str

'Report R-0037, Revision 1': the identity every page carries, with '(number not entered)' in place of what is missing.

missing

missing(report: Any) -> list[str]

The labels of the fields the identification needs that are not entered, in order; empty when it is complete.

amendment

amendment(report: Any) -> int

Which amendment the report is (1 for the first), or 0 when it is not an amendment. Counted from the issue record, never entered.

end_mark

end_mark(report: Any) -> str

The report's last line: 'End of amendment.' for an amendment, otherwise the skeleton's 'End of report.'.

content_hash

content_hash(page: str) -> str

The SHA-256 (hex) of a rendered page without its stamped blocks and whatever fixed its theme: what is compared to tell the issued content from a changed one. A page the shell's viewer draws (report.viewer.viewer_html) is hashed by the report it holds rather than its text, so a new build of the viewer does not read as a change (viewer_content_hash).

viewer_content_hash

viewer_content_hash(page: str) -> str

The SHA-256 (hex) of the report a viewer page holds: its title, marking, stylesheet and blocks, without the stamped blocks (a check's time), each array by its type, shape and bytes.

guard

guard(report: Any, page: str) -> None

Refuse to write page (the report rendered for export) when the report has been issued and the page differs from what was issued.

A report that is a draft, or the feature switched off, passes: a draft says so on every page. An issued report whose content is unchanged passes too, since that is a copy of the issued document.

Raises:

Type Description
ValueError

Naming the issued revision and how to make the change.

issue_ready

issue_ready(report: Any, objects: Mapping[str, Any] | None = None, object_groups: Sequence[Mapping[str, Any]] | None = None) -> str

Check that report can be issued now, and return the status it will carry once issued: 'issued', or 'amended' for an amendment.

Refused: the feature not enabled; a report already issued (a change is an amendment); a field the identification needs not entered; and, with skeleton sections on and objects given, a section still owed (section 9 read off the findings register while that feature is on, as Project.report_check reads it). With the flash report on, what that page still owes (report.flash.check) is read in place of the skeleton's sections, which it does not draw.

Raises:

Type Description
ValueError

For a refusal; the message names what stands in the way.

settled

settled(held: Mapping[str, Any]) -> dict[str, Any]

An identity read from a file: a status of issued or amended with no record behind it, which an interrupted issue once left, is a draft again, so the report can be issued. The record's own entries are kept.

mark_issued

mark_issued(report: Any, status: str) -> dict[str, Any]

Set the status issue_ready returned: around rendering the issued page (the page says it is issued), and when the issue is recorded. Returns the identity as it was, for unmark.

unmark

unmark(report: Any, before: Mapping[str, Any]) -> None

Put back the identity mark_issued returned.

record_issue

record_issue(report: Any, page: str, pdf: bytes, file: str = '') -> dict

Add the revision just issued to the issue record: its number, revision, status and date of issue as entered, the SHA-256 of the PDF and of the page it was printed from, and the file written. Returns the entry.

amend

amend(report: Any, changes: Any, *, revision: str, number: str | None = None) -> None

Make the issued report an amendment, to be issued in its turn.

changes lists what the amendment changes, each a mapping of where (the page or section), was (what it said), now (what it says) and, where appropriate, reason. revision is the amendment's own revision, entered by the author; number, when given, its own report number (otherwise it keeps the original's). The amendment refers to the revision it amends by number, revision and date of issue, taken from the issue record. Its date of issue is cleared, for the author to enter when it is issued.

Refused before anything changes: a report not issued (a draft is changed in place); a change missing its where, was or now; no changes; and a number and revision already issued.

Raises:

Type Description
ValueError

For a refusal; the message names the reason.

TypeError

When a value is of the wrong type.

status_words

status_words(report: Any) -> str

The status as the page says it: 'Draft', 'Draft amendment', 'Issued' or 'Amendment 1'. A flash report (the report feature flash_report) is preliminary whatever its status, and says so first: 'Preliminary (draft)', 'Preliminary (issued)'.

block_html

block_html(report: Any) -> str

The identification block for the first page, as HTML.

The identity rows, then for an amendment the revision it amends and its table of changes, then each person authorizing the report with a blank line for the signature and the date, and the statement that the report is not reproduced except in full. Joined with no white space between tags, since the page keeps a text block's white space.

page_css

page_css(report: Any) -> str

The printed page's margins for report: the laboratory and the report's number and revision at the top of every page, its title and page n of N at the foot. The numbers are the print engine's own page counters, so they are true of whatever it prints. A draft says so beside its number. The classification marking, when there is one, moves from the page's fixed strips into the margins, top and foot center, where it is on every page and over nothing.