@@ -195,14 +195,12 @@ def _exclusion_filterer_ARRIIDT(ctl_transform: CTLTransform) -> bool:
195195PATTERNS_DESCRIPTION_CTL : dict
196196"""
197197
198- PATH_AMF_COMPONENTS_FILE : Path = (
199- Path (__file__ ).parents [0 ] / "resources" / "ACES_AMF_Components.json"
200- )
198+ PATH_TRANSFORMS_FILE : Path = Path (__file__ ).parents [1 ] / "aces" / "transforms.json"
201199
202200"""
203- Path to the *ACES* *AMF* components file.
201+ Path to the *ACES* transforms file containing comprehensive metadata .
204202
205- PATH_AMF_COMPONENTS_FILE : unicode
203+ PATH_TRANSFORMS_FILE : unicode
206204"""
207205
208206
@@ -1461,10 +1459,9 @@ def print_aces_taxonomy() -> None:
14611459def generate_amf_components (
14621460 ctl_transforms : dict [str , dict [str , dict [str , CTLTransform | CTLTransformPair ]]]
14631461 | list [CTLTransform ],
1464- raise_exception : bool = False ,
14651462) -> dict [str , list [str ]]:
14661463 """
1467- Generate the *ACES* *AMF* components from given *ACES* *CTL* transforms.
1464+ Generate the *ACES* *AMF* components from the transforms.json file .
14681465
14691466 Parameters
14701467 ----------
@@ -1473,9 +1470,6 @@ def generate_amf_components(
14731470 :func:`opencolorio_config_aces.classify_aces_ctl_transforms` or
14741471 :func:`opencolorio_config_aces.unclassify_aces_ctl_transforms`
14751472 definitions.
1476- raise_exception : bool, optional
1477- Whether to raise an exception if an *ACES* *ACEStransformID* is
1478- missing.
14791473
14801474 Returns
14811475 -------
@@ -1485,47 +1479,46 @@ def generate_amf_components(
14851479
14861480 amf_components = defaultdict (list )
14871481
1488- with open (PATH_AMF_COMPONENTS_FILE ) as json_file :
1489- content = json_file .readlines ()
1490- content = json .loads (
1491- "\n " .join ([line for line in content if not line .strip ().startswith ("//" )])
1492- )
1493-
1494- attest (content ["header" ]["schema_version" ].split ("." )[0 ] == "1" )
1495-
1496- amf_components_implicit = content ["amf_components" ]
1482+ with open (PATH_TRANSFORMS_FILE ) as json_file :
1483+ json_data = json .load (json_file )
1484+
1485+ all_transforms = [
1486+ transform
1487+ for version_data in json_data ["transformsData" ].values ()
1488+ for transform in version_data ["transforms" ]
1489+ ]
1490+
1491+ for transform in all_transforms :
1492+ transform_id = transform ["transformId" ]
1493+
1494+ if "previousEquivalentTransformIds" in transform :
1495+ for previous_transform_id in transform ["previousEquivalentTransformIds" ]:
1496+ if (
1497+ previous_transform_id
1498+ and transform_id
1499+ and transform_id not in amf_components [previous_transform_id ]
1500+ ):
1501+ amf_components [previous_transform_id ].append (transform_id )
1502+
1503+ inverse_transform_id = transform .get ("inverseTransformId" , "" )
1504+
1505+ if (
1506+ inverse_transform_id
1507+ and transform_id
1508+ and inverse_transform_id not in amf_components [transform_id ]
1509+ ):
1510+ amf_components [transform_id ].append (inverse_transform_id )
1511+
1512+ if (
1513+ inverse_transform_id
1514+ and transform_id
1515+ and transform_id not in amf_components [inverse_transform_id ]
1516+ ):
1517+ amf_components [inverse_transform_id ].append (transform_id )
14971518
14981519 if isinstance (ctl_transforms , Mapping ):
14991520 ctl_transforms = unclassify_ctl_transforms (ctl_transforms )
15001521
1501- # Checking that the explicit "ACEStransformID" do exist.
1502- for aces_transform_id , relations in amf_components_implicit .items ():
1503- explicit_aces_transform_ids = [aces_transform_id ]
1504- explicit_aces_transform_ids .extend (relations )
1505-
1506- for explicit_aces_transform_id in explicit_aces_transform_ids :
1507- filtered_ctl_transforms = filter_ctl_transforms (
1508- ctl_transforms ,
1509- [
1510- lambda x , y = explicit_aces_transform_id : (
1511- x .aces_transform_id .aces_transform_id == y
1512- )
1513- ],
1514- )
1515-
1516- ctl_transform = next (iter (filtered_ctl_transforms ), None )
1517-
1518- if ctl_transform is None :
1519- exception_message = (
1520- f'"aces-dev" has no transform with '
1521- f'"{ explicit_aces_transform_id } " "ACEStransformID!'
1522- )
1523-
1524- if raise_exception :
1525- attest (False , exception_message )
1526- else :
1527- LOGGER .critical (exception_message )
1528-
15291522 for ctl_transform in ctl_transforms :
15301523 aces_transform_id = ctl_transform .aces_transform_id .aces_transform_id
15311524
@@ -1541,22 +1534,21 @@ def generate_amf_components(
15411534 )
15421535 ]:
15431536 for sibling in siblings :
1544- amf_components [aces_transform_id ].append (
1545- sibling .aces_transform_id .aces_transform_id
1546- )
1547-
1548- # Extending with explicit relations.
1549- for aces_transform_id , relations in amf_components_implicit .items ():
1550- amf_components [aces_transform_id ].extend (relations )
1537+ sibling_id = sibling .aces_transform_id .aces_transform_id
1538+ if sibling_id not in amf_components [aces_transform_id ]:
1539+ amf_components [aces_transform_id ].append (sibling_id )
15511540
1552- # Generating the permutations.
1553- for aces_transform_id , relations in amf_components .copy ().items ():
1541+ for aces_transform_id , relations in list (amf_components .items ()):
15541542 for relation in relations :
1555- amf_components [relation ] = sorted (
1556- {* relations , * amf_components [relation ], aces_transform_id } - {relation }
1557- )
1543+ if relation in amf_components :
1544+ amf_components [relation ] = sorted (
1545+ set (amf_components [relation ] + relations + [aces_transform_id ])
1546+ - {relation }
1547+ )
1548+
1549+ result = {key : sorted (set (value )) for key , value in amf_components .items () if value }
15581550
1559- return dict ( amf_components )
1551+ return result
15601552
15611553
15621554if __name__ == "__main__" :
0 commit comments