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: ValueError

Raised 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.schema_path()[source]#

Return the path of the schema document.

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 $defs as ProvenanceRecord and 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 to ProvenanceRecord, to one of the provenance schema’s definitions, or below either. The JavaScript package’s generated schema is 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 additionalProperties checks 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 oneOf or anyOf of const branches lists the admitted constants, as an enum does; a key whose schema refuses every value (not: {} or false) is named as not admitted; a string a not of 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 value and 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 value as validate() does, then lists context_absent at the root for a manifest without @context, bundle_blank at statements (else provenance) for a manifest stating pairs or provenance without an id, whose subject is a blank node, manifestation_unknown at a manifestation the format does not define for its flow-control element or destination, and convention_unknown at 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:
timetoshare.validate.statement_problems(value)[source]#

Return the problems of the statements of value alone.

First, member by member, the manifest’s @context and every statements and provenance member 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 element provenance before statements) checked as validate() 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 subject iri, dangling_target, element_value, representation, calendar_date, provenance_duplicate and belief_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(). value is 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 then graphical.matchstamps checked as validate() 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, or manifest_id where the manifest’s ID repeats one), then the rules of the MatchStamps and their match timestamps (alignment_anchor, matchstamp, groupstamp, match_timestamp), in identity_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 graphical unread checks its MatchStamps with this function. The messages are those of validate(). value is 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. value is in the file form; the rules read its IDs bare.

Raises:

SchemaValidationError – If an ID is not written in the file form.