55Define the *IDT* generator application class.
66"""
77
8+ from __future__ import annotations
9+
810import logging
911import re
12+ import typing
1013from pathlib import Path
1114
12- from colour .hints import List
15+ if typing .TYPE_CHECKING :
16+ from colour .hints import List
17+
1318from colour .utilities import attest , optional
1419
1520import aces .idt .core .common
1621from aces .idt .core .constants import DirectoryStructure
17- from aces .idt .core .trasform_id import generate_idt_urn , is_valid_idt_urn
22+ from aces .idt .core .transform_id import generate_idt_urn , is_valid_csc_urn
1823from aces .idt .framework .project_settings import IDTProjectSettings
1924from aces .idt .generators import GENERATORS
20- from aces .idt .generators .base_generator import IDTBaseGenerator
25+
26+ if typing .TYPE_CHECKING :
27+ from aces .idt .generators .base_generator import IDTBaseGenerator
2128
2229__author__ = "Alex Forsythe, Joshua Pines, Thomas Mansencal, Nick Shaw, Adam Davis"
2330__copyright__ = "Copyright 2022 Academy of Motion Picture Arts and Sciences"
@@ -84,15 +91,17 @@ def generator(self) -> IDTBaseGenerator:
8491 return self ._generator
8592
8693 @generator .setter
87- def generator (self , value : str ):
94+ def generator (self , value : str ) -> None :
8895 """Setter for the **self.generator** property."""
8996
9097 if value not in self .generator_names :
91- raise ValueError (
98+ exception = (
9299 f'"{ value } " generator is invalid, must be one of '
93100 f'"{ self .generator_names } "!'
94101 )
95102
103+ raise ValueError (exception )
104+
96105 self ._generator = GENERATORS [value ](self .project_settings )
97106
98107 @property
@@ -113,7 +122,7 @@ def project_settings(self) -> IDTProjectSettings:
113122 return self ._project_settings
114123
115124 @project_settings .setter
116- def project_settings (self , value : IDTProjectSettings ):
125+ def project_settings (self , value : IDTProjectSettings ) -> None :
117126 """Setter for the **self.project_settings** property."""
118127
119128 self ._project_settings .update (value )
@@ -239,19 +248,18 @@ def _verify_file_type(self) -> None:
239248 """
240249
241250 file_types = set ()
242- for _ , value in self .project_settings .data [
251+ for value in self .project_settings .data [
243252 DirectoryStructure .COLOUR_CHECKER
244- ].items ():
253+ ].values ():
245254 for item in value :
246255 file_types .add (item .suffix )
247256
248257 for item in self .project_settings .data [DirectoryStructure .GREY_CARD ]:
249258 file_types .add (item .suffix )
250259
251260 if len (file_types ) > 1 :
252- raise ValueError (
253- f'Multiple file types found in the project settings: "{ file_types } "'
254- )
261+ msg = f'Multiple file types found in the project settings: "{ file_types } "'
262+ raise ValueError (msg )
255263
256264 self .project_settings .file_type = next (iter (file_types ))
257265
@@ -279,8 +287,9 @@ def extract(self, archive: str, directory: str | None = None) -> str:
279287 json_files = list (root_directory .glob ("*.json" ))
280288
281289 if len (json_files ) > 1 :
282- raise ValueError ('Multiple "JSON" files found in the root directory!' )
283- elif len (json_files ) == 1 :
290+ msg = 'Multiple "JSON" files found in the root directory!'
291+ raise ValueError (msg )
292+ if len (json_files ) == 1 :
284293 json_file = next (iter (json_files ))
285294 LOGGER .info ('Found explicit "%s" "IDT" project settings file.' , json_file )
286295 self .project_settings = IDTProjectSettings .from_file (json_file )
@@ -315,7 +324,9 @@ def process_archive(self, archive: str | None) -> IDTBaseGenerator:
315324 """
316325
317326 if self .generator is None :
318- raise ValueError ('No "IDT" generator was selected!' )
327+ exception = 'No "IDT" generator was set!'
328+
329+ raise ValueError (exception )
319330
320331 if archive is not None :
321332 self .project_settings .working_directory = self .extract (archive )
@@ -324,7 +335,7 @@ def process_archive(self, archive: str | None) -> IDTBaseGenerator:
324335 for exposure in list (
325336 self .project_settings .data [DirectoryStructure .COLOUR_CHECKER ].keys ()
326337 ):
327- images = [ # noqa: C416
338+ images = [
328339 image
329340 for image in self .project_settings .data [
330341 DirectoryStructure .COLOUR_CHECKER
@@ -338,27 +349,29 @@ def process_archive(self, archive: str | None) -> IDTBaseGenerator:
338349 return self .process ()
339350
340351 def process (self ) -> IDTBaseGenerator :
341- """Run the *IDT* generator application process maintaining the execution steps
352+ """
353+ Run the *IDT* generator application process maintaining the execution steps.
342354
343355 Returns
344356 -------
345357 :class:`IDTBaseGenerator`
346358 Instantiated *IDT* generator. after the process has been run
347-
348359 """
360+
349361 self .validate_project_settings ()
350362 self .generator .sample ()
351363 self .generator .sort ()
352- self .generator .remove_clipping ()
364+ self .generator .remove_clipped_samples ()
353365 self .generator .generate_LUT ()
354366 self .generator .filter_LUT ()
355367 self .generator .decode ()
356368 self .generator .optimise ()
369+
357370 return self .generator
358371
359372 def zip (
360373 self , output_directory : Path | str , archive_serialised_generator : bool = False
361- ) -> str :
374+ ) -> Path :
362375 """
363376 Create a *zip* file with the output of the *IDT* application process.
364377
@@ -371,12 +384,14 @@ def zip(
371384
372385 Returns
373386 -------
374- :class:`str `
387+ :class:`pathlib.Path `
375388 *Zip* file path.
376389 """
377390
378391 if not self .generator :
379- raise ValueError ("No Idt Generator Set" )
392+ exception = 'No "IDT" generator was set!'
393+
394+ raise ValueError (exception )
380395
381396 return self .generator .zip (
382397 output_directory , archive_serialised_generator = archive_serialised_generator
@@ -390,8 +405,9 @@ def validate_project_settings(self) -> None:
390405 ValueError
391406 If any of the validations fail
392407 """
408+
393409 # Check the aces_transform_id is a valid idt_urn
394- if not is_valid_idt_urn (self .project_settings .aces_transform_id ):
410+ if not is_valid_csc_urn (self .project_settings .aces_transform_id ):
395411 # If the aces_transform_id is not valid, generate a new one
396412 new_name = generate_idt_urn (
397413 self .project_settings .aces_user_name ,
0 commit comments