Utils Docs

Public api for methods and functions to handle/verify the jsonschemas.

class inspire_schemas.utils.LocalRefResolver(base_uri, referrer, store=(), cache_remote=True, handlers=(), urljoin_cache=None, remote_cache=None)[source]

Bases: jsonschema.validators.RefResolver

Simple resolver to handle non-uri relative paths.


Resolve a uri or relative path to a schema.

inspire_schemas.utils.build_pubnote(title, volume, page_start, page_end, artid)[source]

Build pubnote string from parts (reverse of split_pubnote).


Retrieve the installed path for the given schema.

Parameters:schema (str) – String with the (relative or absolute) url of the schema to validate, for example, ‘records/authors.json’ or ‘jobs.json’, or by just the name like ‘jobs’.
Returns:The path or the given schema name.
Return type:str

Load the given schema from wherever it’s installed.

Parameters:schema_name – Name of the schema to load, for example ‘authors’.

Normalize author name.

Parameters:author (string) – author name
Return name:the name of the author normilized

Split page_artid into page_start/end and artid.


Split pubnote into journal information.

inspire_schemas.utils.validate(data, schema=None)[source]

Validate the given dictionary against the given schema.

  • data (dict) – record to validate.
  • schema (Union[dict, str]) – schema to validate against. If it is a string, it is intepreted as the name of the schema to load (e.g. authors or jobs). If it is None, the schema is taken from data['$schema']. If it is a dictionary, it is used directly.
  • SchemaNotFound – if the given schema was not found.
  • SchemaKeyNotFound – if schema is None and no $schema key was found in data.
  • jsonschema.SchemaError – if the schema is invalid.
  • jsonschema.ValidationError – if the data is invalid.