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
colour_datasets.Record.__init__()
colour_datasets.Record.__str__()
colour_datasets.Record.__repr__()
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:
- property configuration: Configuration#
Getter property for the Colour - Datasets configuration.
- Returns:
Colour - Datasets configuration.
- Return type:
- property repository: str#
Getter property for the Zenodo record local repository.
- Returns:
Zenodo record local repository.
- Return type:
- property title: str#
Getter property for the Zenodo record title.
- Returns:
Zenodo record title.
- Return type:
- 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:
id – Zenodo 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:
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:
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) None [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.
- Return type:
None
Examples
>>> from colour_datasets.utilities import suppress_stdout >>> record = Record.from_id("3245883") >>> record.remove() >>> with suppress_stdout(): ... record.pull() >>> record.synced() True