Find Thesaurus#

Help#

metacatalog.api.find_thesaurus(return_iterator: typing_extensions.Literal[False] = False) List['Thesaurus']#
metacatalog.api.find_thesaurus(return_iterator: typing_extensions.Literal[True] = False) Query

Retun one or many thesaurii references from the database on exact matches. You can use ‘%’ and ‘*’ as wildcards and prepend a str with ! to invert the filter.

..versionadded:: 0.1.10

Parameters:
  • session (sqlalchemy.Session) – SQLAlchemy session connected to the database.

  • id (integer) – Database unique ID of the requested record. Will return only one record.

  • uuid (str) –

    New in version 0.6.6.

    Find by version 4 UUID. If uuid is given, all other options will be ignored.

  • name (str) – Short name of the Thesaurus. No wildcard use is possible. Names are unique, thus no multiple thesaurii will be found.

  • title (str) – Full title attribute of the requested thesaurii. Multiple record return is possible.

  • organisation (str) – Organisation name of the requested thesaurii. Multiple record return is possible.

  • description (str) – Description of the thesaurus. The decription field is optional and some records may not be found.

  • return_iterator (bool) – If True, an iterator returning the requested objects instead of the objects themselves is returned.

Returns:

records – List of matched Thesaurus instances.

Return type:

list of metacatalog.models.Thesaurus

Example#

[1]:
from metacatalog import api
from pprint import pprint

session = api.connect_database()
[2]:
gcmd = api.find_thesaurus(session, name='GCMD')[0]
pprint(gcmd.to_dict())
{'description': 'NASA Global Clime change Master Dictionary Science Keywords',
 'id': 1,
 'name': 'GCMD',
 'organisation': 'NASA',
 'title': 'NASA/GCMD Earth Science Keywords',
 'url': 'https://gcmdservices.gsfc.nasa.gov/kms/concepts/concept_scheme/sciencekeywords/?format=xml',
 'uuid': '2e54668d-8fae-429f-a511-efe529420b12'}
[3]:
print('Associated Keywords found: %d' % len(gcmd.keywords))
Associated Keywords found: 3206