pyflightstream.utils (stable)¶
Generated from the docstrings at build time: every one of the 36 names in the __all__ of pyflightstream.utils has an entry below. The names a guide or an example uses come first; the others follow under Advanced.
Maintainer utilities that are not part of a run.
Pipeline role: none. Nothing in the run pipeline imports this subpackage, which is what keeps it outside the layer rule rather than at a position within it (CONTRIBUTING.md Layout, AD-01).
The modules occupy two dependency layers. :mod:~pyflightstream.utils.manual
and :mod:~pyflightstream.utils.errors import nothing from this package
and sit at the bottom beside :mod:pyflightstream._errors, so they can
be used from any layer. :mod:~pyflightstream.utils.cli is an ENTRY
POINT above :mod:pyflightstream.commands, which it reads to answer
what the database already records, the same shape as
:mod:pyflightstream.reference.
What belongs here is the work of KEEPING the package current rather than
of using it: reading a new vendor manual, comparing it against the
command database, reporting what a new release added. That work runs on
the maintainer's machine against licensed material in _private/.
pyfs-manual register writes documented version rows for commands a manual supports. Other
proposals remain drafts for review.
The layer statement above is unchanged by it, and the split is why.
:func:~pyflightstream.utils.manual.insert_version_row takes the text
of a chapter file and returns the edited text; it opens nothing.
The registration I/O lives in :mod:~pyflightstream.utils.database. It reads and writes
chapter bytes and validates every edit against the command schema before writing any of them.
SO THIS SUBPACKAGE HAS THREE POSITIONS, not the two the statement above
enumerates: manual and errors at the bottom, and cli and
database above :mod:pyflightstream.commands. database is
deliberately NOT re-exported from this module, and that is load bearing
rather than an oversight: re-exporting it would make
import pyflightstream.utils pull :mod:pyflightstream.commands in,
and cost manual the property that it can be used from any layer.
Import it by its own name.
What does NOT belong here is anything a user's run depends on. A helper
that a script, a campaign or a parser needs is part of that layer and
belongs in it; putting it here would make utils a bag that everything
reaches into, which is the shape this subpackage is most at risk of
becoming.
Advanced¶
pyflightstream.utils.CommandEntryLike
¶
Bases: Protocol
The one field :func:stale_citations reads off a command entry.
versions
property
¶
versions: Mapping[str, VersionRowLike]
Evidence per canonical version identifier.
pyflightstream.utils.Coverage
dataclass
¶
Coverage(
absent: tuple[str, ...] = (),
recorded: tuple[str, ...] = (),
undocumented: tuple[str, ...] = (),
details: dict[str, ManualCommand] = dict(),
)
What one manual says that the database does not, and the reverse.
Attributes:
| Name | Type | Description |
|---|---|---|
absent |
tuple of str
|
Documented by the manual and not recorded in the database. |
recorded |
tuple of str
|
In both. |
undocumented |
tuple of str
|
Recorded in the database and not found in this manual. Not an error by itself: a command removed by a later build, or one documented only in another edition, lands here. |
pyflightstream.utils.Edition
dataclass
¶
Edition(
*,
label: str,
manual: Path,
chapter: tuple[int, int],
index: tuple[int, int] | None = None,
source: str | None = None,
)
One manual to read, and where its two chapters sit in it.
A registered FlightStream build and the pdf that documents it. The page ranges are per edition because scripting-reference pagination differs between manuals.
KEYWORD-ONLY, and that is about chapter and index
specifically. They are two page ranges of the same type, so
positionally they are interchangeable and swapping them constructs
cleanly: the sweep then reads the Script Index as the scripting
reference, reports hundreds of false absences, and nothing anywhere
can detect it. Named arguments are the only thing that separates
them.
Attributes:
| Name | Type | Description |
|---|---|---|
label |
str
|
Canonical version identifier, for example |
manual |
Path
|
Path of the manual pdf. Licensed vendor material, given explicitly and never guessed, and never committed. |
chapter |
tuple of int
|
First and last page of the scripting reference, one-based inclusive. |
index |
tuple of int or None
|
First and last page of the Script Index, if the edition has one. It supplies the section label only, so an edition without one is swept with its commands unlabelled rather than skipped. |
source |
str or None
|
Citation id of this edition, for example |
pyflightstream.utils.EditionDelta
dataclass
¶
EditionDelta(
*,
name: str,
verdict: EditionVerdict,
page: int | None = None,
previous_page: int | None = None,
differs_in: tuple[str, ...] = (),
)
What a new edition says about one command, against its predecessor.
Produced by :func:documentation_delta, one per command the database
records, so a caller can tell the five states apart without
re-deriving them.
KEYWORD-ONLY, and that is about page and previous_page
specifically, exactly as it is for :class:Edition's two page
ranges. They are two fields of the same type sitting adjacent, so
positionally they are interchangeable and swapping them constructs
cleanly: :attr:repaginated still answers true, and the caller
writes the PREDECESSOR's page into a row citing the new edition's
source. That is a wrong citation in the shipped database with every
guard green, and nothing but the keyword separates the two.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Command name. |
verdict |
EditionVerdict
|
Which of the five states this command is in. |
page |
int or None
|
Page of the NEW edition, where it documents the command. None where this edition does not document it at all. |
previous_page |
int or None
|
Page of the predecessor, where it did. None where the predecessor did not document it. |
differs_in |
tuple of str
|
For |
pyflightstream.utils.EditionVerdict
¶
Bases: StrEnum
Closed vocabulary for one command's relationship to a predecessor edition.
Five values distinguish unchanged, changed, arrived, dropped and absent commands. Callers can decide which rows to write without rechecking the predecessor mapping or reconstructing missing distinctions.
pyflightstream.utils.ManualCallError
¶
Bases: PyflightstreamError, TypeError
A drafting function was called with the wrong argument shape.
The library raises nothing of this class today. propose_type takes its
two strings as keywords only (PFS-2022.05), so a call with the strings
positional, twice or missing raises Python's own TypeError, which is
what the signature itself refuses with. The class stays in the catalogue
for callers that name it.
TypeError as the second base, because that is what a wrong call
shape raised before the catalogue held a class for it, and what a
caller written against it would still catch (FR-39).
pyflightstream.utils.ManualCommand
dataclass
¶
ManualCommand(
name: str,
page: int,
inline_args: tuple[str, ...] = (),
sample: tuple[str, ...] = (),
section: str | None = None,
parameters: Mapping[str, str] = dict(),
description: str = "",
)
One command as the manual describes it, before any judgement.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Command name as printed. |
page |
int
|
Page of the manual that introduces it, one-based, as a reader
would cite it in a |
inline_args |
tuple of str
|
Placeholder names from the signature line, in order. These are the arguments written on the command's own line. Arguments that continue onto following lines do not appear here, which is the single largest reason a proposal needs review. |
sample |
tuple of str
|
The lines of the sample block, comment lines removed. The first
is the command with its inline arguments; any further line is a
continuation, and the shape of those lines is what
:func: |
section |
str or None
|
Section the Script Index files it under, when an index was parsed and named it. |
parameters |
mapping of str to str
|
The manual's own parameter table, placeholder name to the prose
describing it, for the commands that carry one. This is the
third source, after the signature and the sample, and it is the
only one that says anything about an argument's TYPE. The prose
is licensed manual text: it is read at run time from the pdf the
caller passes and is never written into anything this module
renders (invariant 1), which is why :func: |
description |
str
|
The complete command block, ending at the next signature, with whitespace normalized and page-number footers removed. Compared at runtime only; renderers never reproduce this licensed text. |
continuation_lines
property
¶
continuation_lines: tuple[str, ...]
Sample lines after the first, which the signature never shows.
pyflightstream.utils.ManualDraftError
¶
Bases: PyflightstreamError, ValueError
A draft was asked for something a manual cannot support.
Raised where the caller asks the drafting functions to record more
than the source they are reading can justify, the sharp case being a
verified or broken status: those are promoted from a
committed probe report by pyfs-qa apply-compat, never from a page
citation (CONTRIBUTING.md invariant 3).
ValueError as the second base, because that is what this refusal
raised before the catalogue existed and what a caller written against
it would still catch (FR-39).
pyflightstream.utils.Reachability
dataclass
¶
Reachability(
*,
findings: tuple[UnreachableCommand, ...],
unmeasured: tuple[str, ...],
)
What a reachability sweep found, and what it could not look at.
Two fields rather than one tuple, because an edition whose label the
registry cannot resolve is not a command and was being reported as
one: it entered the findings with the string (every command) in
the command field, so the CLI counted it in "N command(s) an edition
documents that its build cannot emit" and --fail-if-absent
failed on it. That is a build nobody has registered yet, which
Edition.label explicitly promises can be swept.
Attributes:
| Name | Type | Description |
|---|---|---|
findings |
tuple of UnreachableCommand
|
One per command an edition documents that its build cannot emit. Empty when every edition read is complete. |
unmeasured |
tuple of str
|
Labels the version registry could not turn into exactly one build, either unregistered or a vendor alias several builds share. Nothing is known about their commands, which is a different statement from knowing they cannot be emitted. |
pyflightstream.utils.RegistryLike
¶
Bases: Protocol
What the citation and reachability checks need of the database.
Both attributes, because the two checks need different halves:
:func:stale_citations walks commands and
:func:unreachable_commands also asks for_version what a build
can emit. The protocol therefore requires both attributes.
pyflightstream.utils.StaleCitation
dataclass
¶
StaleCitation(
*,
command: str,
edition: str,
cited: int,
found: int | None,
reason: str,
)
A version row whose cited page does not hold the command.
Attributes:
| Name | Type | Description |
|---|---|---|
command |
str
|
Command name the row belongs to. |
edition |
str
|
Label of the edition the row cites. |
cited |
int
|
Page number written in the row's note. |
found |
int or None
|
Page the edition actually prints the signature on, or None. |
reason |
str
|
Which finding this is, because |
pyflightstream.utils.SurfaceChange
dataclass
¶
SurfaceChange(
*,
older: str,
newer: str,
gained: tuple[str, ...],
lost: tuple[str, ...],
)
What one build's scripting surface gained and lost against the one before it.
Attributes:
| Name | Type | Description |
|---|---|---|
older |
str
|
Label of the earlier edition. |
newer |
str
|
Label of the later edition. |
gained |
tuple of str
|
Commands the later edition documents and the earlier one does not, sorted. |
lost |
tuple of str
|
Commands the earlier edition documents and the later one does not, sorted. Lost means the later manual stops printing the command, which is not the same as the solver refusing it: a command can disappear from a manual and keep working. Deciding which happened needs a probe, so this is evidence for a question rather than an answer to it. |
pyflightstream.utils.SweptCommand
dataclass
¶
SweptCommand(
name: str,
editions: tuple[str, ...],
pages: dict[str, int],
section: str | None,
detail: ManualCommand,
)
One command as the whole set of editions describes it.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Command name as printed. |
editions |
tuple of str
|
Labels of the editions whose chapter body documents it, in the order the editions were given. A command absent from this tuple for a given edition is one that edition does not document, which is the fact a version row must reflect. |
pages |
dict of str to int
|
Page carrying the signature, per edition label. The pages differ per edition and each version row cites its own. |
section |
str or None
|
Section that documents it, from the first edition whose index names it. |
detail |
ManualCommand
|
What the newest edition given states about it, for drafting. |
pyflightstream.utils.TYPE_RULES
module-attribute
¶
TYPE_RULES: tuple[TypeRule, ...] = (
TypeRule(
"opening",
"the description opens with what the value is",
_read_opening,
),
TypeRule(
"integer-word",
"the description says the value is whole",
_read_integer_word,
),
TypeRule(
"dimension",
"the parameter carries a physical dimension",
_read_dimension,
),
TypeRule(
"enumeration",
"the description enumerates the accepted tokens",
_read_enumeration,
),
TypeRule(
"alternatives",
"the description spells the alternatives with 'or'",
_read_alternatives,
),
TypeRule(
"toggle",
"the description offers the two toggle tokens",
_read_toggle,
),
)
pyflightstream.utils.TypeRule
dataclass
¶
TypeRule(
name: str,
reason: str,
read: Callable[
[str, str], tuple[str, tuple[str, ...]] | None
],
)
One rule of :func:propose_type, and its position in the order.
Rules form an ordered list. Their precedence is part of the inference contract and is visible to both readers and tests.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Short identifier, used by the tests that pin the order. |
reason |
str
|
What :func: |
read |
callable
|
Takes the upper-cased placeholder and the description, and
returns |
pyflightstream.utils.UnreachableCommand
dataclass
¶
UnreachableCommand(
*, command: str, edition: str, reason: str
)
A command an edition documents that its build cannot emit.
Attributes:
| Name | Type | Description |
|---|---|---|
command |
str
|
Command name as the edition prints it. |
edition |
str
|
Label of the edition that documents it. |
reason |
str
|
|
pyflightstream.utils.VersionRowLike
¶
Bases: Protocol
The two fields :func:stale_citations reads off a version row.
Declared as a protocol rather than left implicit, because this
module sits below commands in the dependency order and cannot
import the real type. Every read of that type was a getattr with
a swallowing default, so renaming VersionStatus.note would have
made the check return no findings forever with a green suite; the
tier-1 test asserting the real registry satisfies this is what turns
that silence into a red.
pyflightstream.utils.coverage_against
¶
coverage_against(
manual: Mapping[str, ManualCommand],
*,
recorded: Iterable[str],
) -> Coverage
Compare a parsed manual against the names the database records.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manual
|
mapping of str to ManualCommand
|
Output of :func: |
required |
recorded
|
iterable of str
|
Command names the database holds, typically
|
required |
Returns:
| Type | Description |
|---|---|
Coverage
|
The three sets, each sorted, plus the parsed detail of every absent command so a maintainer can start writing entries without re-reading the manual. |
pyflightstream.utils.documentation_delta
¶
documentation_delta(
previous: Mapping[str, ManualCommand],
current: Mapping[str, ManualCommand],
*,
recorded: Iterable[str],
) -> tuple[EditionDelta, ...]
Classify every recorded command against two parsed editions.
THE COMPARISON IS OF WHAT THE EDITION SAYS, not of where it says it, and that is the whole reason this function exists. A rule keyed on the page number cannot see a command that moved: a local reflow repaginates a run of commands by one, and under a page rule every one of them falls out of a bulk pass although most are word for word what they were. Comparing the parsed records handles it and is sensitive to changes anywhere in the command block. Whitespace and page-number footers are normalized; an unchanged page number is not evidence of unchanged text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
previous
|
mapping of str to ManualCommand
|
Output of :func: |
required |
current
|
mapping of str to ManualCommand
|
Output of :func: |
required |
recorded
|
iterable of str
|
Command names the database holds. Commands the new edition documents that are not among these are not classified here; a caller reports them separately, because entering a new command is a different piece of work from carrying an existing one forward. |
required |
Returns:
| Type | Description |
|---|---|
tuple of EditionDelta
|
One per recorded command, sorted by name. |
pyflightstream.utils.edition_surfaces
¶
edition_surfaces(
editions: Iterable[Edition],
*,
reader: Callable[..., Mapping[int, str]] | None = None,
) -> dict[str, tuple[str, ...]]
Read each edition and return the command names it documents.
The whole surface, not the part the database lacks, which is what
:func:manual_editions reports. Both read the chapter body the same
way, and the difference is the question: a sweep asks what is
missing from the database, this asks what each build documents so
two builds can be compared.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
editions
|
iterable of Edition
|
The manuals to read. Order is preserved in the result and is
the caller's to choose; :func: |
required |
reader
|
callable
|
What turns a manual and a page range into text, defaulting to
:func: |
None
|
Returns:
| Type | Description |
|---|---|
dict of str to tuple of str
|
Command names per edition label, sorted within each edition, with the editions in the order given. |
Raises:
| Type | Description |
|---|---|
ManualDraftError
|
If no edition is given, or if two editions share a label. A duplicate label would silently overwrite the first reading and report a build compared against itself. |
pyflightstream.utils.insert_version_row
¶
insert_version_row(
text: str,
*,
command: str,
canonical: str,
status: str,
note: str,
) -> str
Insert one single-line version row into a chapter file's text.
The function renders its row through :func:pyflightstream._yamlflow.flow_mapping. It accepts
no pre-rendered YAML, so escaping and validation remain within the library.
KEYWORD-ONLY after the text, for the reason the neighbouring
:class:Edition is: command, canonical, status and
note are four strings, so positionally they are interchangeable
and a swap of the middle two constructs cleanly.
AT THE END OF THE BLOCK rather than in release order, and that is deliberate: the existing rows are NOT in release order in every entry, so inserting by order would reorder files this has no business reordering.
Preserve all bytes outside the inserted row, including each line's existing terminator. In particular, do not normalize CRLF chapters to LF while inserting a version row.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The chapter file, whole. |
required |
command
|
str
|
Entry to edit. Its |
required |
canonical
|
str
|
Build the row is for. Refused if the entry already has one. |
required |
status
|
str
|
Evidence status for that build, written as a bare token. This function does NOT judge it: which statuses exist and which may be written from a reading is the command database's rule and the caller's to obey (CONTRIBUTING.md invariant 3). |
required |
note
|
str
|
Provenance of the row, quoted and escaped on the way in. A
citation, for example |
required |
Returns:
| Type | Description |
|---|---|
str
|
The edited text. |
Raises:
| Type | Description |
|---|---|
ManualDraftError
|
If the entry is not in this file, has no |
pyflightstream.utils.manual_editions
¶
manual_editions(
editions: Iterable[Edition],
*,
recorded: Iterable[str],
reader: Callable[..., Mapping[int, str]] | None = None,
) -> tuple[SweptCommand, ...]
Read every manual edition and report what none of them has an entry for.
manual_editions is the public Python API; pyfs-manual sweep
is the CLI subcommand that calls it.
The multi-edition form of :func:coverage_against, and it exists
because the single-edition one answers a question no sweep asks. A
command absent from one edition may be recorded from another, and a
command the database lacks must be entered for EVERY edition that
documents it at once (the chapter rule in docs/srs/data-model.md).
Both need the union, so reading the editions one at a time and
comparing four reports by eye is the step this removes.
Reading is body-driven: the signature headings of the chapter are
the command set, and the Script Index is consulted only for section
labels. That is not interchangeable with reading the index, which
is incomplete: NEW_CCS_WING_FLAP_COVE has a heading on p.299 of
one edition and no index row, so an index-driven sweep reports it
covered forever.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
editions
|
iterable of Edition
|
The manuals to read, oldest first by convention so that
:attr: |
required |
recorded
|
iterable of str
|
Command names the database holds, typically
|
required |
reader
|
callable
|
What turns a manual and a page range into text, defaulting to
:func: |
None
|
Returns:
| Type | Description |
|---|---|
tuple of SweptCommand
|
Every command documented by at least one edition and recorded by none, sorted by name. |
Raises:
| Type | Description |
|---|---|
ManualDraftError
|
If no edition is given. With no manual read, nothing can be documented and the answer is zero absent, which is indistinguishable from the complete database this is run to confirm. A configuration error that reads as the good outcome is the one shape worth refusing outright. |
pyflightstream.utils.parse_script_index
¶
parse_script_index(
pages: Mapping[int, str],
) -> dict[str, str]
Read the manual's own Script Index into command and section.
The index is the authoritative command list: it is the vendor's enumeration rather than a heuristic over headings, which is why it is preferred over scanning the chapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pages
|
mapping of int to str
|
Extracted text of the index pages, keyed by one-based page number. Pass only the index pages; passing the whole manual would admit body text that happens to match the line shape. |
required |
Returns:
| Type | Description |
|---|---|
dict of str to str
|
Command name to the section naming it, first occurrence winning. |
pyflightstream.utils.parse_signatures
¶
parse_signatures(
pages: Mapping[int, str],
*,
sections: Mapping[str, str] | None = None,
) -> dict[str, ManualCommand]
Read every command's signature and sample from the scripting chapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pages
|
mapping of int to str
|
Extracted text of the scripting reference pages, keyed by one-based page number. |
required |
sections
|
mapping of str to str
|
Output of :func: |
None
|
Returns:
| Type | Description |
|---|---|
dict of str to ManualCommand
|
Command name to what the manual states about it. First definition wins, so a later cross-reference cannot overwrite the page a reader should cite. |
Notes
The pages are read as one stream, preserving samples and parameter tables across page boundaries.
It was found by comparing two editions of one manual, where the
consequence is sharp. The vendor repaginated one chapter by a page,
which split DISABLE_WAKE_NODES_ON_TRAILING_EDGE across a break in
the newer edition alone; the comparison then read a full record
against a truncated one and reported a documentation change the
vendor had not made. Worse in the other direction: with 22 commands
of that edition truncated, three deliberately planted grammar edits
below a break all compared EQUAL, so a real vendor change would have
been carried forward as "same grammar".
The page a command is CITED at is still the page carrying its signature line, which is what a reader turns to.
A line that is nothing but its own page number is dropped while the stream is built. It is the extraction's footer, and joined into the stream it lands in the middle of a block and reads as content: 20 commands had one as the first line of their sample.
pyflightstream.utils.propose_layout
¶
propose_layout(command: ManualCommand) -> tuple[str, str]
Suggest a database layout for a command, with the reason.
A PROPOSAL, and the second element says what it was read from so a
reviewer can disagree cheaply. The five layouts are the database's
own vocabulary: bare, inline, param_lines,
payload_lines and keyword_block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
ManualCommand
|
The command as the manual reader parsed it. |
required |
Returns:
| Type | Description |
|---|---|
tuple of str
|
|
pyflightstream.utils.propose_type
¶
propose_type(
*, placeholder: str, description: str
) -> tuple[str | None, tuple[str, ...], str]
Suggest an argument type from the manual's parameter table.
Both strings are keyword-only (PFS-2022.05). A positional Python call raises TypeError; naming placeholder and description prevents accidentally exchanging two otherwise valid strings.
The parameter table supplies type information absent from signatures
and samples. An unknown type remains unresolved so the caller can
write ??? rather than invent a type.
The rules are tried in a stated order and the order is load-bearing. A counting or indexing opening decides before either enum rule, because both enum rules read tokens out of a sentence and a count whose description mentions two alternatives is still a count. Both enum rules then read only the sentence carrying the phrase that introduces the set.
Nothing of the description reaches the return value. The reason is a sentence about the SHAPE the rule matched, not a paraphrase of the manual, so a draft carries no licensed text (invariant 1).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
placeholder
|
str
|
Parameter name as the manual prints it, for example
|
required |
description
|
str
|
The manual's prose for that parameter, as
:attr: |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
A positional call, which Python itself refuses on this signature. |
pyflightstream.utils.read_edition
¶
read_edition(
edition: Edition,
*,
reader: Callable[..., Mapping[int, str]] | None = None,
) -> dict[str, ManualCommand]
Parse one edition's scripting reference, sections included.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edition
|
Edition
|
A row of the edition manifest. |
required |
reader
|
callable
|
Page reader, defaulting to :func: |
None
|
Returns:
| Type | Description |
|---|---|
dict of str to ManualCommand
|
What that edition states about each command it documents. |
pyflightstream.utils.read_edition_manifest
¶
read_edition_manifest(
path: str | Path,
) -> tuple[Edition, ...]
Read an edition manifest, the file that makes a sweep repeatable.
The manifest is a list of mappings with the keys of :class:Edition,
chapter and index written as FIRST-LAST. It is a file
rather than repeated command-line flags because it is the thing a
new build EDITS: registering one is adding a row, and the row is
then under the maintainer's own version control rather than retyped
from a session note.
It is never committed here. It names paths of licensed manuals, and
those live in _private/ (CONTRIBUTING.md invariant 1).
Named for the manifest and not for the editions, unlike the
neighbouring :func:read_pdf_pages: this opens a small text file and
returns descriptors, and opens no manual at all.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Manifest file, YAML. |
required |
Returns:
| Type | Description |
|---|---|
tuple of Edition
|
In the order written. |
Raises:
| Type | Description |
|---|---|
ManualDraftError
|
If the file is not a list of mappings, if a row lacks |
Examples:
A manifest with one edition, as it would be written by hand::
- label: "26.121"
source: FSM-26.121
manual: _private/manual/user-manual-26121.pdf
chapter: 284-379
index: 380-386
pyflightstream.utils.read_pdf_pages
¶
read_pdf_pages(
path: str | Path, *, first: int, last: int
) -> dict[int, str]
Extract the text of a page range from a manual pdf.
Separated from every function above so the parsing is testable without a pdf and without the optional dependency: everything else in this module takes text.
Require a valid, keyword-only range of one-based page numbers. Reversed bounds must not produce an empty mapping that coverage would interpret as a manual documenting no commands; zero must not index the last PDF page or produce a p.0 citation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
The manual. It is licensed vendor material, lives in
|
required |
first
|
int
|
One-based, inclusive page range. Keyword-only. |
required |
last
|
int
|
One-based, inclusive page range. Keyword-only. |
required |
Returns:
| Type | Description |
|---|---|
dict of int to str
|
Extracted text keyed by one-based page number, one entry per page of the requested range. |
Raises:
| Type | Description |
|---|---|
ManualDraftError
|
If the range is not one-based and ascending, or if it reaches past the end of the document. A short read is never returned. |
MissingExtraError
|
When the |
pyflightstream.utils.render_chapter
¶
render_chapter(
commands: Iterable[ManualCommand],
*,
source: str,
versions: Mapping[str, str],
) -> str
Render several entries as one chapter file body, sorted by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commands
|
iterable of ManualCommand
|
The entries to render. |
required |
source
|
str
|
Manual source id for the citation, for example |
required |
versions
|
mapping of str to str
|
Canonical version to status, as :func: |
required |
Returns:
| Type | Description |
|---|---|
str
|
The chapter header, then one entry per command, sorted by name. |
pyflightstream.utils.render_entry
¶
render_entry(
command: ManualCommand,
*,
source: str,
versions: Mapping[str, str],
phase: str | None = None,
) -> str
Render one command as a database entry, for a person to review.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
ManualCommand
|
Parsed entry, from :func: |
required |
source
|
str
|
Manual source id for the citation, for example |
required |
versions
|
mapping of str to str
|
Canonical version to status. Only |
required |
phase
|
str
|
Overrides the phase proposed from the section. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
YAML for one entry, with |
Raises:
| Type | Description |
|---|---|
ManualDraftError
|
If a status other than |
pyflightstream.utils.sample_contradiction
¶
sample_contradiction(
command: ManualCommand,
*,
index: int,
proposed: str | None,
values: tuple[str, ...] = (),
) -> str | None
Report the sample token a proposed type would refuse.
The parameter table is not the only thing the manual says about an argument: the page also PRINTS a call. A proposal read from the table alone is therefore a reading of one source that another source on the same page can already falsify, and this is that second reading.
What it does NOT claim is that the manual contradicts itself. Four causes produce the same signal and only a person can tell them apart: the table offered "label or number" and only the labels were read; the table is genuinely incomplete; the sample is a typo; or the argument list is out of step with the signature so the compared token belongs to a different argument. All four mean the proposal must not be written, which is the only decision this function makes.
A parameter table can disagree with its sample. CAD_BODY_ROTATE has a
parameter table naming the three axis letters and a sample calling it
with the index 2, on the same page, in every edition; three
SWEEPER_SET_*_SWEEP commands omit a mode their own samples use.
Why this belongs here rather than in a review checklist: both facts
are already in :class:ManualCommand, so the tool had everything it
needed and compared nothing. The earlier measurement that certified
:func:propose_type as never disagreeing with a hand-authored type
could not have caught this, because those entries were authored from
the same parameter table; the tool and the reviewer read one source
and agreed with each other about it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
ManualCommand
|
Parsed entry. Its sample supplies the evidence and its
|
required |
index
|
int
|
ZERO-based position in |
required |
proposed
|
str or None
|
Type :func: |
required |
values
|
tuple of str
|
Token set of an enumeration proposal. |
()
|
Returns:
| Type | Description |
|---|---|
str or None
|
The token the sample passes at that position, when the proposed type would refuse it. None when the proposal accepts the token, and also when the sample cannot answer: a command with no sample, a sample whose first line is not the call, or a call with fewer tokens than the signature has placeholders. Those three are silent rather than reported because the absence of a sample is not evidence of agreement, and a caller that treated None as confirmation would be reading it as one. |
Raises:
| Type | Description |
|---|---|
ManualDraftError
|
If |
pyflightstream.utils.stale_citations
¶
stale_citations(
editions: Iterable[Edition],
*,
recorded: RegistryLike,
reader: Callable[..., Mapping[int, str]] | None = None,
) -> tuple[StaleCitation, ...]
Check every version row's page citation against the manual it names.
Check that cited pages still match the manual's command locations. A regenerated conversion can shift pagination while leaving a cited page number valid but pointing to the wrong command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
editions
|
iterable of Edition
|
The manuals to check against. The manual side comes first and
the database is keyword-only, matching
:func: |
required |
recorded
|
RegistryLike
|
The loaded database, used through |
required |
reader
|
callable
|
What turns a manual and a page range into text, defaulting to
:func: |
None
|
Returns:
| Type | Description |
|---|---|
tuple of StaleCitation
|
One entry per disagreeing row, sorted by command then edition. |
Raises:
| Type | Description |
|---|---|
ManualDraftError
|
If no edition is given, or if two editions share a label, or if the mapping exposes no version rows at all. All three are configuration errors that would otherwise return an empty tuple, and an empty tuple from this function reads as a clean bill. |
Notes
Three classes of row are NOT checked, and silence about a row is therefore never a claim that the row is right.
A removed row is skipped: its citation addresses an ABSENCE and
names the pages the command is not on, so checking it the same way
would report every honest removal record as a defect.
A row whose note carries no page cannot be checked, and most rows do not carry one. Neither can a row whose edition the manifest does not list, and that one differs in kind from the other three: the run has no reading to check it against, so it is not an outcome of this check at all.
Each run records how the rows it saw ended, in
:data:citation_reach, one count per outcome of
:data:CITATION_REACH_OUTCOMES per edition. Those four partition
the rows seen for that edition, so a caller can say WHY a row went
unchecked rather than inferring one reason for all of them
(OPS-2003.10.02). Rows of an unlisted edition appear in none of the
four, for the reason in the paragraph above.
A note citing a page RANGE is satisfied by any page in it. Twenty-six shipped rows cite one, and reading only the first page of a span reports a correct citation as wrong whenever the signature heading sits on the second.
The SOURCE is checked too, where the manifest records one: a note citing FSM-26.120 on a row keyed to the edition FSM-26.121 was reading a different document, and page numbers between those two differ by a uniform three, so a coincidence is cheap.
pyflightstream.utils.surface_changes
¶
surface_changes(
surfaces: Mapping[str, Iterable[str]],
) -> tuple[SurfaceChange, ...]
Compare each edition's command surface with the one before it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
surfaces
|
mapping of str to iterable of str
|
Command names per edition label, in release order. Python mappings preserve insertion order and this relies on it, so a caller that sorts the labels as strings gets the wrong neighbours: "26.100" sorts before "26.101" by luck, and "26.12" sorts after both as a string. |
required |
Returns:
| Type | Description |
|---|---|
tuple of SurfaceChange
|
One entry per consecutive pair, empty when fewer than two editions are given. |
pyflightstream.utils.unreachable_commands
¶
unreachable_commands(
editions: Iterable[Edition],
*,
recorded: RegistryLike,
reader: Callable[..., Mapping[int, str]] | None = None,
) -> Reachability
Report, per edition, the documented commands its build cannot emit.
This is the row-level half of the coverage question, and it exists
because the entry-level half cannot answer it.
:func:manual_editions compares the manuals against the set of entry
NAMES, so an entry that exists but carries no row for one edition is
invisible to it: the sweep reports zero absent while that build's
emitter refuses a command the caller's own manual documents.
Reachability, not row presence, is the measure, because a genuine hotfix inherits its base release's records: 26.122 carries twenty direct rows and reaches 375, and counting rows would report it as missing hundreds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
editions
|
iterable of Edition
|
The manuals to read. |
required |
recorded
|
RegistryLike
|
The loaded database. Typed loosely because this module sits
below |
required |
reader
|
callable
|
What turns a manual and a page range into text, defaulting to
:func: |
None
|
Returns:
| Type | Description |
|---|---|
Reachability
|
Its |
Raises:
| Type | Description |
|---|---|
ManualDraftError
|
If no edition is given, or if two editions share a label. Same
two refusals as :func: |
pyflightstream.utils.write_chapter
¶
write_chapter(
body: str,
*,
path: str | Path,
write: bool = False,
overwrite: bool = False,
) -> str
Write a drafted chapter, but only when asked.
The default is a dry run, and the reason is the measurement in this module's own docstring: the drafts reproduce 77 percent of hand-authored argument lists, so writing them unreviewed into the database the emitter validates against would put invented grammar in front of other people's scripts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body
|
str
|
Output of :func: |
required |
path
|
(str or Path, keyword - only)
|
Destination. Point it at a scratch file to review before moving
anything into |
required |
write
|
(bool, keyword - only)
|
False, the default, writes nothing. True writes |
False
|
overwrite
|
(bool, keyword - only)
|
False, the default, refuses a |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A sentence saying what happened, for a caller to print. |
Raises:
| Type | Description |
|---|---|
ManualDraftError
|
If |