Skip to content

Commit 8628d48

Browse files
Rename functions related to reading/parsing CLF to be consistent with similar functions exposed in colour.
1 parent 13d5bbc commit 8628d48

File tree

4 files changed

+34
-30
lines changed

4 files changed

+34
-30
lines changed

colour_clf_io/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
__version__ = f"{__major_version__}.{__minor_version__}.{__change_version__}"
105105

106106

107-
def read_clf(path: str | Path) -> ProcessList:
107+
def read_clf_from_file(path: str | Path) -> ProcessList:
108108
"""
109109
Read given *CLF* file and return a *ProcessList*.
110110
@@ -134,7 +134,7 @@ def read_clf(path: str | Path) -> ProcessList:
134134
return process_list
135135

136136

137-
def parse_clf(text: str | bytes) -> ProcessList | None:
137+
def read_clf(text: str | bytes) -> ProcessList | None:
138138
"""
139139
Read given string as a *CLF* file and return a *ProcessList*.
140140

colour_clf_io/tests/test_clf_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def snippet_to_process_list(
8080

8181
doc = wrap_snippet(snippet)
8282

83-
return colour_clf_io.parse_clf(doc)
83+
return colour_clf_io.read_clf(doc)
8484

8585

8686
def snippet_as_tmp_file(snippet: str) -> str:

colour_clf_io/tests/test_clf_parsing.py

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import colour_clf_io.elements
1212
import colour_clf_io.process_nodes
1313
import colour_clf_io.values
14-
from colour_clf_io import parse_clf, read_clf
14+
from colour_clf_io import read_clf, read_clf_from_file
1515
from colour_clf_io.errors import ParsingError
1616

1717
from .test_clf_common import wrap_snippet
@@ -49,7 +49,9 @@ def test_read_sample_document_1(self) -> None:
4949
Test parsing of the sample file `ACES2065_1_to_ACEScct.xml`.
5050
"""
5151

52-
clf_data = read_clf(os.path.join(ROOT_CLF, "ACES2065_1_to_ACEScct.xml"))
52+
clf_data = read_clf_from_file(
53+
os.path.join(ROOT_CLF, "ACES2065_1_to_ACEScct.xml")
54+
)
5355

5456
assert clf_data is not None
5557
assert clf_data.description == ["Conversion from linear ACES2065-1 to ACEScct"]
@@ -76,7 +78,7 @@ def test_read_sample_document_2(self) -> None:
7678
Test parsing of the sample file `LMT Kodak 2383 Print Emulation.xml`.
7779
"""
7880

79-
clf_data = read_clf(
81+
clf_data = read_clf_from_file(
8082
os.path.join(ROOT_CLF, "LMT Kodak 2383 Print Emulation.xml")
8183
)
8284

@@ -91,7 +93,9 @@ def test_read_sample_document_3(self) -> None:
9193
Test parsing of the sample file `LMT_ARRI_K1S1_709_EI800_v3.xml`.
9294
"""
9395

94-
clf_data = read_clf(os.path.join(ROOT_CLF, "LMT_ARRI_K1S1_709_EI800_v3.xml"))
96+
clf_data = read_clf_from_file(
97+
os.path.join(ROOT_CLF, "LMT_ARRI_K1S1_709_EI800_v3.xml")
98+
)
9599

96100
assert clf_data is not None
97101
assert clf_data.description == ["An ARRI based look"]
@@ -117,7 +121,7 @@ def test_LUT1D_example(self) -> None:
117121
</LUT1D>
118122
"""
119123

120-
doc = parse_clf(wrap_snippet(example))
124+
doc = read_clf(wrap_snippet(example))
121125

122126
assert doc is not None
123127

@@ -155,7 +159,7 @@ def test_LUT3D_example(self) -> None:
155159
</LUT3D>
156160
""" # noqa: E501
157161

158-
doc = parse_clf(wrap_snippet(example))
162+
doc = read_clf(wrap_snippet(example))
159163

160164
assert doc is not None
161165

@@ -201,7 +205,7 @@ def test_matrix_example_1(self) -> None:
201205
</Matrix>
202206
"""
203207

204-
doc = parse_clf(wrap_snippet(example))
208+
doc = read_clf(wrap_snippet(example))
205209

206210
assert doc is not None
207211

@@ -241,7 +245,7 @@ def test_matrix_example_2(self) -> None:
241245
</Matrix>
242246
""" # noqa: E501
243247

244-
doc = parse_clf(wrap_snippet(example))
248+
doc = read_clf(wrap_snippet(example))
245249

246250
assert doc is not None
247251

@@ -295,7 +299,7 @@ def test_range_example(self) -> None:
295299
</Range>
296300
"""
297301

298-
doc = parse_clf(wrap_snippet(example))
302+
doc = read_clf(wrap_snippet(example))
299303

300304
assert doc is not None
301305

@@ -323,7 +327,7 @@ def test_log_example_1(self) -> None:
323327
</Log>
324328
"""
325329

326-
doc = parse_clf(wrap_snippet(example))
330+
doc = read_clf(wrap_snippet(example))
327331

328332
assert doc is not None
329333

@@ -353,7 +357,7 @@ def test_log_example_2(self) -> None:
353357
</Log>
354358
"""
355359

356-
doc = parse_clf(wrap_snippet(example))
360+
doc = read_clf(wrap_snippet(example))
357361

358362
assert doc is not None
359363

@@ -394,7 +398,7 @@ def test_exponent_example_1(self) -> None:
394398
</Exponent>
395399
"""
396400

397-
doc = parse_clf(wrap_snippet(example))
401+
doc = read_clf(wrap_snippet(example))
398402

399403
assert doc is not None
400404

@@ -422,7 +426,7 @@ def test_exponent_example_2(self) -> None:
422426
</Exponent>
423427
"""
424428

425-
doc = parse_clf(wrap_snippet(example))
429+
doc = read_clf(wrap_snippet(example))
426430

427431
assert doc is not None
428432

@@ -453,7 +457,7 @@ def test_exponent_example_3(self) -> None:
453457
</Exponent>
454458
"""
455459

456-
doc = parse_clf(wrap_snippet(example))
460+
doc = read_clf(wrap_snippet(example))
457461

458462
assert doc is not None
459463

@@ -484,7 +488,7 @@ def test_exponent_example_4(self) -> None:
484488
</Exponent>
485489
"""
486490

487-
doc = parse_clf(wrap_snippet(example))
491+
doc = read_clf(wrap_snippet(example))
488492

489493
assert doc is not None
490494

@@ -522,7 +526,7 @@ def test_ASC_CDL_example(self) -> None:
522526
</ASC_CDL>
523527
"""
524528

525-
doc = parse_clf(wrap_snippet(example))
529+
doc = read_clf(wrap_snippet(example))
526530

527531
assert doc is not None
528532

@@ -571,7 +575,7 @@ def test_ACES2065_1_to_ACEScg_example(self) -> None:
571575
</ProcessList>
572576
"""
573577

574-
doc = parse_clf(example)
578+
doc = read_clf(example)
575579

576580
assert doc is not None
577581

@@ -610,7 +614,7 @@ def test_ACES2065_1_to_ACEScct_example(self) -> None:
610614
</ProcessList>
611615
""" # noqa: E501
612616

613-
doc = parse_clf(example)
617+
doc = read_clf(example)
614618

615619
assert doc is not None
616620

@@ -653,7 +657,7 @@ def test_CIE_XYZ_to_CIELAB_example(self) -> None:
653657
</ProcessList>
654658
"""
655659

656-
doc = parse_clf(example)
660+
doc = read_clf(example)
657661

658662
assert doc is not None
659663

@@ -676,7 +680,7 @@ def test_fail_on_invalid_namespace(self) -> None:
676680
</ProcessList>
677681
"""
678682

679-
pytest.raises(ParsingError, parse_clf, example)
683+
pytest.raises(ParsingError, read_clf, example)
680684

681685
@pytest.mark.with_ocio
682686
def test_CLF_from_OCIO(self) -> None:
@@ -693,7 +697,7 @@ def test_CLF_from_OCIO(self) -> None:
693697
)
694698
clf_text = ocio_transform.write("Academy/ASC Common LUT Format").encode()
695699

696-
doc = parse_clf(clf_text)
700+
doc = read_clf(clf_text)
697701

698702
assert doc is not None
699703

colour_clf_io/tests/test_clf_writing.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import colour_clf_io.elements
99
import colour_clf_io.process_nodes
1010
import colour_clf_io.values
11-
from colour_clf_io import parse_clf, write_clf
11+
from colour_clf_io import read_clf, write_clf
1212

1313
from .test_clf_common import wrap_snippet
1414

@@ -46,11 +46,11 @@ def assert_valid_roundtrip_for_file(path: str) -> None:
4646

4747

4848
def assert_valid_roundtrip_for_doc(doc: str) -> None:
49-
doc_original = parse_clf(doc)
49+
doc_original = read_clf(doc)
5050
assert doc_original is not None
5151
xml = write_clf(doc_original)
5252
assert xml is not None
53-
doc_after_roundtrip = parse_clf(xml)
53+
doc_after_roundtrip = read_clf(xml)
5454
assert doc_original == doc_after_roundtrip
5555

5656

@@ -323,7 +323,7 @@ def test_ACES2065_1_to_ACEScg_example(self) -> None:
323323
</ProcessList>
324324
"""
325325

326-
doc = parse_clf(example)
326+
doc = read_clf(example)
327327

328328
assert doc is not None
329329

@@ -362,7 +362,7 @@ def test_ACES2065_1_to_ACEScct_example(self) -> None:
362362
</ProcessList>
363363
""" # noqa: E501
364364

365-
doc = parse_clf(example)
365+
doc = read_clf(example)
366366

367367
assert doc is not None
368368

@@ -405,7 +405,7 @@ def test_CIE_XYZ_to_CIELAB_example(self) -> None:
405405
</ProcessList>
406406
"""
407407

408-
doc = parse_clf(example)
408+
doc = read_clf(example)
409409

410410
assert doc is not None
411411

0 commit comments

Comments
 (0)