Skip to content

Commit 59c1d74

Browse files
committed
Merge branch 'feature/v0.2.4' into develop
2 parents 692bb1e + eb63f4f commit 59c1d74

File tree

7 files changed

+51
-16
lines changed

7 files changed

+51
-16
lines changed

TODO.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,36 @@ Colour - Datasets - TODO
44
TODO
55
----
66

7+
- colour_datasets/__init__.py
78

9+
- Line 78 : # TODO: Remove legacy printing support when deemed appropriate.
10+
11+
12+
- colour_datasets/records/zenodo.py
13+
14+
- Line 451 : # TODO: Remove the following space escaping: The new Zenodo API is not quoting filenames properly thus we are temporarily escaping spaces for now. https://github.com/colour-science/colour-datasets/issues/ 36issuecomment-1773464695
15+
16+
17+
- colour_datasets/utilities/common.py
18+
19+
- Line 42 : # TODO: Use *colour* definition.
20+
21+
22+
- colour_datasets/loaders/kuopio.py
23+
24+
- Line 310 : # TODO: Implement support for *Natural Colors*: https://sandbox.zenodo.org/record/315640 http://www.uef.fi/web/spectral/natural-colors
25+
26+
27+
- colour_datasets/loaders/xrite2016.py
28+
29+
- Line 109 : # TODO: Implement support for "CGATS" file format in "Colour": https://github.com/colour-science/colour/issues/354
30+
31+
32+
- colour_datasets/loaders/dyer2017.py
33+
34+
- Line 141 : # TODO: Re-instate "manufacturer", "model", "illuminant" and "type" attributes according to outcome of https://github.com/ampas/rawtoaces/issues/114. Those attributes are currently stored in "self._kwargs".
35+
- Line 928 : # TODO: Re-instate "manufacturer", "model", "illuminant" and "type" attributes according to outcome of https://github.com/ampas/rawtoaces/issues/114.
36+
- Line 1430 : # TODO: Re-instate "manufacturer", "model", "illuminant" and "type" attributes according to outcome of https://github.com/ampas/rawtoaces/issues/114.
837

938
About
1039
-----

colour_datasets/loaders/asano2015.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,3 +342,9 @@ def build_Asano2015(load: bool = True) -> DatasetLoader_Asano2015:
342342
_DATASET_LOADER_ASANO2015.load()
343343

344344
return _DATASET_LOADER_ASANO2015
345+
346+
347+
if __name__ == "__main__":
348+
import colour_datasets
349+
350+
colour_datasets.load("3252742")

colour_datasets/records/tests/test_zenodo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@ def test__str__(self):
159159
-----
160160
161161
- camlist&equipment.txt : https://zenodo.org/api/records/3245883/files/\
162-
camlist&equipment.txt
162+
camlist&equipment.txt/content
163163
- camspec_database.txt : https://zenodo.org/api/records/3245883/files/\
164-
camspec_database.txt
165-
- urls.txt : https://zenodo.org/api/records/3245883/files/urls.txt"""
164+
camspec_database.txt/content
165+
- urls.txt : https://zenodo.org/api/records/3245883/files/urls.txt/content"""
166166
)[1:],
167167
)
168168

colour_datasets/records/zenodo.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import json
1515
import os
16+
import re
1617
import shutil
1718
import stat
1819
import tempfile
@@ -204,8 +205,8 @@ def strip_html(text: str) -> str:
204205

205206
files = "\n".join(
206207
[
207-
f"- {file_data['filename']} : {file_data['links']['self']}"
208-
for file_data in sorted(files, key=lambda x: x["filename"])
208+
f'- {file_data["key"]} : {file_data["links"]["self"]}'
209+
for file_data in sorted(files, key=lambda x: x["key"])
209210
]
210211
)
211212

@@ -388,31 +389,29 @@ def pull(self, use_urls_txt_file: bool = True, retries: int = 3):
388389
# given by the content of :attr:`URLS_TXT_FILE` attribute file.
389390
urls_txt = None
390391
for file_data in self.data["files"]:
391-
if file_data["filename"] == self._configuration.urls_txt_file:
392+
if file_data["key"] == self._configuration.urls_txt_file:
392393
urls_txt = file_data
393394
break
394395

395-
def urls_download(urls: Dict, is_content_url=False):
396+
def urls_download(urls: Dict) -> None:
396397
"""Download given urls."""
397398

398399
for url, md5 in urls.items():
400+
filename = re.sub("/content$", "", url)
399401
filename = os.path.join(
400402
downloads_directory,
401403
urllib.parse.unquote( # pyright: ignore
402-
url.split("/")[-1]
404+
filename.split("/")[-1]
403405
),
404406
)
405-
url = ( # noqa: PLW2901
406-
f"{url}/content" if is_content_url else url
407-
)
408407
url_download(url, filename, md5.split(":")[-1], retries)
409408

410409
try:
411410
if use_urls_txt_file and urls_txt:
412411
urls = {}
413412
urls_txt_file = tempfile.NamedTemporaryFile(delete=False).name
414413
url_download(
415-
urls_txt["links"]["download"],
414+
urls_txt["links"]["self"],
416415
urls_txt_file,
417416
urls_txt["checksum"].split(":")[-1],
418417
retries,
@@ -445,7 +444,7 @@ def urls_download(urls: Dict, is_content_url=False):
445444

446445
urls = {}
447446
for file_data in self.data["files"]:
448-
if file_data["filename"] == self._configuration.urls_txt_file:
447+
if file_data["key"] == self._configuration.urls_txt_file:
449448
continue
450449

451450
# TODO: Remove the following space escaping: The new Zenodo API
@@ -457,7 +456,7 @@ def urls_download(urls: Dict, is_content_url=False):
457456

458457
urls[url] = file_data["checksum"].split(":")[-1]
459458

460-
urls_download(urls, is_content_url=True)
459+
urls_download(urls)
461460

462461
deflate_directory = os.path.join(
463462
self.repository, self._configuration.deflate_directory

colour_datasets/utilities/common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
]
4040

4141

42+
# TODO: Use *colour* definition.
4243
class suppress_stdout:
4344
"""A context manager and decorator temporarily suppressing standard output."""
4445

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ coveralls = "*"
6262
flynt = "*"
6363
invoke = "*"
6464
jupyter = "*"
65-
pre-commit = "*"
65+
pre-commit = ">= 3.5"
6666
pyright = "*"
6767
pytest = "*"
6868
pytest-cov = "*"

utilities/export_todo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,6 @@ def export_todo_items(todo_items: dict, file_path: str):
123123
os.chdir(os.path.dirname(__file__))
124124

125125
export_todo_items(
126-
extract_todo_items(os.path.join("..", "colour_checker_detection")),
126+
extract_todo_items(os.path.join("..", "colour_datasets")),
127127
os.path.join("..", "TODO.rst"),
128128
)

0 commit comments

Comments
 (0)