Tools for the creation of JSON-LD metadata

JSON-LD - the serialization format used for metadata in CLDF datasets - supports nested data. To make creating (and reading) this data simpler, this module provides a Python API to build data structures which “know” how to read from/serialize to JSON-LD.

Usage:

>>> from clldutils.metadata import *
>>> md = Metadata(
...     title='The Data',
...     publisher=Publisher(name='Data Press', place='anywhere'),
...     license=License(name='CC-BY-4.0'))
>>> md.to_jsonld()['dc:license']
OrderedDict([('name', 'Creative Commons Attribution 4.0'),
             ('url', 'https://creativecommons.org/licenses/by/4.0/'),
             ('icon', 'cc-by.png')])
>>> Metadata.from_jsonld(md.to_jsonld()).publisher.place
'anywhere'
class clldutils.metadata.Publisher(name=None, place=None, url=None, contact=None)[source]

The entity publishing a dataset.

Variables:
  • name – Name of the publisher.

  • place – Place or address of the publisher, used in “traditional” publisher formats.

  • url – URL linking to the “homepage” of the publisher.

  • contact – An email address under which to contact the publisher of a dataset.

class clldutils.metadata.License(name='Creative Commons Attribution 4.0 International License', url='https://creativecommons.org/licenses/by/4.0/', icon='cc-by.png')[source]

The license under which a dataset is published, characterized with name, URL and an icon.

class clldutils.metadata.Metadata(publisher=Publisher(name=None, place=None, url=None, contact=None), license=License(name='Creative Commons Attribution 4.0 International License', url='https://creativecommons.org/licenses/by/4.0/', icon='cc-by.png'), url=None, title=None, description=None)[source]

Metadata about the published version(s) of a dataset.

Variables:
  • publisher (Publisher) – The organisation or institution publishing the dataset.

  • license (License) – The license under which the dataset can be used.

  • url (str) – A URL under which the dataset can be browsed.

  • title (str) – The title of the dataset.

  • description (str) –

to_jsonld()[source]

Returns a dict suitable for serialization as JSON-LD object, with the metadata tagged with suitable common properties.

Return type:

collections.OrderedDict