MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/MaterialX / buildTypeGroups

Function buildTypeGroups

python/Scripts/comparenodedefs.py:33–51  ·  view source on GitHub ↗

Build type groups from standard library TypeDefs. Derives colorN, vectorN, matrixNN groups from type naming patterns.

(stdlib)

Source from the content-addressed store, hash-verified

31 return {td.getName() for td in stdlib.getTypeDefs()}
32
33def buildTypeGroups(stdlib):
34 '''
35 Build type groups from standard library TypeDefs.
36 Derives colorN, vectorN, matrixNN groups from type naming patterns.
37 '''
38 groups = {}
39 for td in stdlib.getTypeDefs():
40 name = td.getName()
41 # Match colorN, vectorN patterns (color3, vector2, etc.)
42 match = re.match(r'^(color|vector)(\d)$', name)
43 if match:
44 groupName = f'{match.group(1)}N'
45 groups.setdefault(groupName, set()).add(name)
46 continue
47 # Match matrixNN pattern (matrix33, matrix44)
48 match = re.match(r'^matrix(\d)\1$', name)
49 if match:
50 groups.setdefault('matrixNN', set()).add(name)
51 return groups
52
53def buildTypeGroupVariables(typeGroups):
54 '''Build type group variables (e.g., colorM from colorN) for "must differ" constraints.'''

Callers 1

parseSpecDocumentFunction · 0.85

Calls 4

setClass · 0.50
getNameMethod · 0.45
matchMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected