colour_datasets.Record#

class colour_datasets.Record(data: dict, configuration: Configuration | None = None)[source]#

Bases: object

Define an object storing a Zenodo record data and providing methods to sync it in a local repository.

Parameters:
  • data (dict) – Zenodo record data.

  • configuration (Configuration | None) – Colour - Datasets configuration.

Attributes

Methods

Examples

>>> record = Record(json_open("https://zenodo.org/api/records/3245883"))
>>> record.id
'3245883'
>>> record.title
'Camera Spectral Sensitivity Database - Jiang et al. (2013)'
property data: dict#

Getter property for the Zenodo record data.

Returns:

Zenodo record data.

Return type:

dict

property configuration: Configuration#

Getter property for the Colour - Datasets configuration.

Returns:

Colour - Datasets configuration.

Return type:

colour_datasets.Configuration

property repository: str#

Getter property for the Zenodo record local repository.

Returns:

Zenodo record local repository.

Return type:

str

property id: str#

Getter property for the Zenodo record id.

Returns:

Zenodo record id.

Return type:

str

property title: str#

Getter property for the Zenodo record title.

Returns:

Zenodo record title.

Return type:

str

static from_id(id_: str, configuration: Configuration | None = None, retries: int = 3) Record[source]#

colour_datasets.Record class factory that builds an instance using given Zenodo record id.

Parameters:
  • idZenodo record id.

  • configuration (Configuration | None) –

    configuration

    Colour - Datasets configuration.

  • retries (int) – Number of retries in case where a networking error occurs.

  • id_ (str) –

Returns:

Zenodo record data.

Return type:

colour_datasets.Record

Examples

>>> Record.from_id("3245883").title
'Camera Spectral Sensitivity Database - Jiang et al. (2013)'
synced() bool[source]#

Return whether the Zenodo record data is synced to the local repository.

Returns:

Whether the Zenodo record data is synced to the local repository.

Return type:

bool

Examples

>>> from colour_datasets.utilities import suppress_stdout
>>> record = Record.from_id("3245883")
>>> with suppress_stdout():
...     record.pull()
>>> record.synced()
True
>>> record.remove()
>>> record.synced()
False
pull(use_urls_txt_file: bool = True, retries: int = 3)[source]#

Pull the Zenodo record data to the local repository.

Parameters:
  • use_urls_txt_file (bool) – Whether to use the urls.txt file: if such a file is present in the Zenodo record data, the urls it defines take precedence over the record data files. The later will be used in the eventuality where the urls are not available.

  • retries (int) – Number of retries in case where a networking error occurs or the MD5 hash is not matching.

Examples

>>> from colour_datasets.utilities import suppress_stdout
>>> record = Record.from_id("3245883")
>>> record.remove()
>>> with suppress_stdout():
...     record.pull()
>>> record.synced()
True
remove()[source]#

Remove the Zenodo record data local repository.

Examples

>>> from colour_datasets.utilities import suppress_stdout
>>> record = Record.from_id("3245883")
>>> with suppress_stdout():
...     record.pull()
>>> record.remove()
>>> record.synced()
False