timetoshare.validate#
The TimeToShare schema, its validator and its public diagnostics.
A manifest is validated in its file form, every ID written # followed by
the ID: the schema check and the search for unknown keys read the value as
given. Every other check reads the manifest with bare IDs (with_bare_ids),
the finite rule, which runs first, included: their messages quote IDs bare
('clt_1') and the paths of the checks after the schema name the keys of
graphical.order bare too. The rules run in one order: the version
marker, the finite rule, the earlier form of flow control
(timetoshare.validation.flow), the schema, the representation of
own-axis values, the identity rules, then the statement rules
(timetoshare.validation.statements).
- timetoshare.validate.SCHEMA_VERSION = '0.2.0'#
The schema version this package reads and writes, the only one it supports.
- exception timetoshare.validate.UnsupportedVersionError(version)[source]#
Bases:
ValueErrorRaised when a manifest’s version marker names another version.
- timetoshare.validate.data_root()[source]#
The directory holding the schema, catalogue, fonts and fixtures.
- timetoshare.validate.provenance_schema_path()[source]#
Return the path of the provenance schema, the one provenance entry.
- timetoshare.validate.MANIFEST_DOCUMENT = 'timetoshare.schema.json'#
The file name of the manifest schema.
- timetoshare.validate.PROVENANCE_DOCUMENT = 'provenance.schema.json'#
The file name of the provenance schema beside the manifest schema.
- timetoshare.validate.PROVENANCE_DEFINITION = 'ProvenanceRecord'#
The name of the provenance schema’s root among the bundled definitions.
- timetoshare.validate.bundle_schemas(manifest, provenance)[source]#
Return the manifest schema with the provenance schema bundled into it.
The provenance schema’s root joins
$defsasProvenanceRecordand its own definitions join under their names; every reference between the two documents becomes a local reference to the same place in the bundle, so the bundle is one document whose references are all local. A reference into the manifest schema keeps its pointer (the whole manifest schema is#); one into the provenance schema, by its file name or from inside it, leads toProvenanceRecord, to one of the provenance schema’s definitions, or below either. The JavaScript package’s generatedschemais the same bundle.- Raises:
ValueError – If a definition of the provenance schema has the name of one of the manifest schema, or a reference leads to a document that is neither of the two.
- timetoshare.validate.load_schema()[source]#
Return the cached schema, the provenance schema bundled into it.
The manifest schema with the provenance schema bundled (
bundle_schemas()); treat it as read-only.
- timetoshare.validate.select(errors)[source]#
The error the one path rule reports.
The deepest leaf wins; among leaves equally deep, the one whose path comes first, compared element by element (indices by number, keys by code point); among leaves at one path, the first reported. The walk reports the members an
additionalPropertieschecks in no fixed order, so the order of the paths, never the order of the report, decides between two places.
- timetoshare.validate.worded(error)[source]#
The message of a selected error, naming what is admitted where the walk does not.
A value outside a
oneOforanyOfofconstbranches lists the admitted constants, as anenumdoes; a key whose schema refuses every value (not: {}orfalse) is named as not admitted; a string anotof patterns or words refuses names the part refused and what is not admitted. Every other error keeps the walk’s message.
- timetoshare.validate.validate(value)[source]#
Check
valueand raise the first schema or semantic violation.
- timetoshare.validate.unknown_keys(value)[source]#
Return sorted unknown keys from the same schema walk used for validation.
- timetoshare.validate.manifest_warnings(value)[source]#
Return the warnings of a valid manifest, sorted by path, then code.
Validates
valueasvalidate()does, then listscontext_absentat the root for a manifest without@context,bundle_blankatstatements(elseprovenance) for a manifest stating pairs or provenance without anid, whose subject is a blank node,manifestation_unknownat a manifestation the format does not define for its flow-control element or destination, andconvention_unknownat a FlowMap’s convention that is none of the format’s, each as{"code": ..., "path": [...], "message": ...}. Paths compare element by element, an index before a key.- Raises:
SchemaValidationError – If the manifest violates a rule.
UnsupportedVersionError – If it names another version.
- timetoshare.validate.statement_problems(value)[source]#
Return the problems of the statements of
valuealone.First, member by member, the manifest’s
@contextand everystatementsandprovenancemember of the manifest, a timeline at any depth or a region (subject order: the manifest, then root by root the timeline, its regions and its children, depth first; within an elementprovenancebeforestatements) checked asvalidate()checks them, each member’s first problem at its path: a number that is not finite (finite_number), else the schema (schema), reported by the one path rule. Where no member has a problem, every problem of the statement rules follows, not only the first:context,reserved_key, then subject by subjectiri,dangling_target,element_value,representation,calendar_date,provenance_duplicateandbelief_actor.Nothing outside the statements is refused, and the version marker is not read: a manifest whose timelines break other rules but whose statements are sound has no problem here. A library that reads only part of a manifest checks its statements with this function. The messages are those of
validate().valueis in the file form; the rules read its IDs bare, and an ID written without#is read as it stands.
- timetoshare.validate.matchstamp_problems(value)[source]#
Return the problems of the named MatchStamps and their match timestamps alone.
First, each match timestamp (a named timestamp with
matchstamp: true) and thengraphical.matchstampschecked asvalidate()checks them, each one’s first problem at its path: a number that is not finite (finite_number), else the schema (schema), reported by the one path rule. Where none has a problem, every problem beyond the schema follows, not only the first: an ID of a MatchStamp or an alignment anchor that the manifest holds twice (duplicate_id, ormanifest_idwhere the manifest’s ID repeats one), then the rules of the MatchStamps and their match timestamps (alignment_anchor,matchstamp,groupstamp,match_timestamp), inidentity_problems()’ order.Nothing else is refused: an ordinary timestamp, the styles and rules, the timelines and the statements are not read beyond what the MatchStamps name. A library that keeps the rest of
graphicalunread checks its MatchStamps with this function. The messages are those ofvalidate().valueis in the file form; the rules read its IDs bare, and an ID written without#is read as it stands.
- timetoshare.validate.identity_problems(value)[source]#
Return all semantic violations in the established identity order.
Root by root: duplicates, dangling targets, conversion maps, containment and segment lines; then the IDs unique across the manifest (the roots’ trees, the group IDs, the MeasureMap IDs, the named timestamps’ IDs, the elisions’ IDs, the named MatchStamps’ IDs each followed by its alignment anchors’ IDs, the resources’ IDs, and last the manifest ID); then group members, graphical orders, named timestamps, elisions, named MatchStamps and resources.
valueis in the file form; the rules read its IDs bare.- Raises:
SchemaValidationError – If an ID is not written in the file form.