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

Function findLibraryMatch

python/Scripts/comparenodedefs.py:701–729  ·  view source on GitHub ↗

Find a matching library signature. Returns (matchType, libSig, extraInLib, extraInSpec).

(specSig, libSigs)

Source from the content-addressed store, hash-verified

699 return differences
700
701def findLibraryMatch(specSig, libSigs):
702 '''Find a matching library signature. Returns (matchType, libSig, extraInLib, extraInSpec).'''
703 specInputs = set(specSig.inputs)
704 specOutputs = set(specSig.outputs)
705
706 for libSig in libSigs:
707 libInputs = set(libSig.inputs)
708 libOutputs = set(libSig.outputs)
709
710 # Check for exact match
711 if specInputs == libInputs and specOutputs == libOutputs:
712 return MatchType.EXACT, libSig, None, None
713
714 # Check for different input sets (same outputs, different inputs)
715 if specOutputs == libOutputs and specInputs != libInputs:
716 # If there are common inputs, verify they have the same types
717 commonInputNames = {name for name, _ in specInputs} & {name for name, _ in libInputs}
718 if commonInputNames:
719 specInputDict = dict(specSig.inputs)
720 libInputDict = dict(libSig.inputs)
721 typesMatch = all(specInputDict[n] == libInputDict[n] for n in commonInputNames)
722 if not typesMatch:
723 continue # Common inputs have different types - not a match
724
725 extraInLib = tuple(sorted(libInputs - specInputs))
726 extraInSpec = tuple(sorted(specInputs - libInputs))
727 return MatchType.DIFFERENT_INPUTS, libSig, extraInLib, extraInSpec
728
729 return None, None, None, None
730
731def compareNodes(specNodes, libNodes, libDefaults, geompropNames, compareDefaults=False):
732 '''Compare nodes between spec and library. Returns list of Differences.'''

Callers 1

compareNodesFunction · 0.85

Calls 3

dictClass · 0.85
tupleClass · 0.85
setClass · 0.50

Tested by

no test coverage detected