|
14 | 14 |
|
15 | 15 | import aces.idt.core.common |
16 | 16 | from aces.idt.core.constants import DirectoryStructure |
| 17 | +from aces.idt.core.trasform_id import generate_idt_urn, is_valid_idt_urn |
17 | 18 | from aces.idt.framework.project_settings import IDTProjectSettings |
18 | 19 | from aces.idt.generators import GENERATORS |
19 | 20 | from aces.idt.generators.base_generator import IDTBaseGenerator |
@@ -147,25 +148,33 @@ def _update_project_settings_from_implicit_directory_structure( |
147 | 148 | for exposure_directory in colour_checker_directory.iterdir(): |
148 | 149 | if re.match(r"-?\d", exposure_directory.name): |
149 | 150 | EV = exposure_directory.name |
150 | | - self.project_settings.data[DirectoryStructure.COLOUR_CHECKER][ |
151 | | - EV |
152 | | - ] = list((colour_checker_directory / exposure_directory).glob("*.*")) |
| 151 | + self.project_settings.data[DirectoryStructure.COLOUR_CHECKER][EV] = [ |
| 152 | + file |
| 153 | + for file in (colour_checker_directory / exposure_directory).glob( |
| 154 | + "*.*" |
| 155 | + ) |
| 156 | + if not file.name.startswith(".") |
| 157 | + ] |
153 | 158 |
|
154 | 159 | flatfield_directory = ( |
155 | 160 | root_directory / DirectoryStructure.DATA / DirectoryStructure.FLATFIELD |
156 | 161 | ) |
157 | 162 | if flatfield_directory.exists(): |
158 | | - self.project_settings.data[DirectoryStructure.FLATFIELD] = list( |
159 | | - flatfield_directory.glob("*.*") |
160 | | - ) |
| 163 | + self.project_settings.data[DirectoryStructure.FLATFIELD] = [ |
| 164 | + file |
| 165 | + for file in flatfield_directory.glob("*.*") |
| 166 | + if not file.name.startswith(".") |
| 167 | + ] |
161 | 168 |
|
162 | 169 | grey_card_directory = ( |
163 | 170 | root_directory / DirectoryStructure.DATA / DirectoryStructure.GREY_CARD |
164 | 171 | ) |
165 | 172 | if grey_card_directory.exists(): |
166 | | - self.project_settings.data[DirectoryStructure.GREY_CARD] = list( |
167 | | - flatfield_directory.glob("*.*") |
168 | | - ) |
| 173 | + self.project_settings.data[DirectoryStructure.GREY_CARD] = [ |
| 174 | + file |
| 175 | + for file in grey_card_directory.glob("*.*") |
| 176 | + if not file.name.startswith(".") |
| 177 | + ] |
169 | 178 |
|
170 | 179 | def _verify_archive(self, root_directory: Path | str) -> None: |
171 | 180 | """ |
@@ -289,7 +298,7 @@ def extract(self, archive: str, directory: str | None = None) -> str: |
289 | 298 |
|
290 | 299 | return directory |
291 | 300 |
|
292 | | - def process(self, archive: str | None) -> IDTBaseGenerator: |
| 301 | + def process_archive(self, archive: str | None) -> IDTBaseGenerator: |
293 | 302 | """ |
294 | 303 | Compute the *IDT* either using given archive *zip* file path or the |
295 | 304 | current *IDT* project settings if not given. |
@@ -326,13 +335,25 @@ def process(self, archive: str | None) -> IDTBaseGenerator: |
326 | 335 | float(exposure) |
327 | 336 | ] = images |
328 | 337 |
|
| 338 | + return self.process() |
| 339 | + |
| 340 | + def process(self) -> IDTBaseGenerator: |
| 341 | + """Run the *IDT* generator application process maintaining the execution steps |
| 342 | +
|
| 343 | + Returns |
| 344 | + ------- |
| 345 | + :class:`IDTBaseGenerator` |
| 346 | + Instantiated *IDT* generator. after the process has been run |
| 347 | +
|
| 348 | + """ |
| 349 | + self.validate_project_settings() |
329 | 350 | self.generator.sample() |
330 | 351 | self.generator.sort() |
| 352 | + self.generator.remove_clipping() |
331 | 353 | self.generator.generate_LUT() |
332 | 354 | self.generator.filter_LUT() |
333 | 355 | self.generator.decode() |
334 | 356 | self.generator.optimise() |
335 | | - |
336 | 357 | return self.generator |
337 | 358 |
|
338 | 359 | def zip( |
@@ -360,3 +381,24 @@ def zip( |
360 | 381 | return self.generator.zip( |
361 | 382 | output_directory, archive_serialised_generator=archive_serialised_generator |
362 | 383 | ) |
| 384 | + |
| 385 | + def validate_project_settings(self) -> None: |
| 386 | + """Run validation checks on the project settings. |
| 387 | +
|
| 388 | + Raises |
| 389 | + ------ |
| 390 | + ValueError |
| 391 | + If any of the validations fail |
| 392 | + """ |
| 393 | + # Check the aces_transform_id is a valid idt_urn |
| 394 | + if not is_valid_idt_urn(self.project_settings.aces_transform_id): |
| 395 | + # If the aces_transform_id is not valid, generate a new one |
| 396 | + new_name = generate_idt_urn( |
| 397 | + self.project_settings.aces_user_name, |
| 398 | + self.project_settings.encoding_colourspace, |
| 399 | + self.project_settings.encoding_transfer_function, |
| 400 | + 1, |
| 401 | + ) |
| 402 | + # Update the project settings with the new name, if this is still invalid |
| 403 | + # it will raise an error from the setter |
| 404 | + self.project_settings.aces_transform_id = new_name |
0 commit comments