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

Function formatDifference

python/Scripts/comparenodedefs.py:199–230  ·  view source on GitHub ↗

Format a Difference for display, returning a list of lines.

(diff)

Source from the content-addressed store, hash-verified

197 libDefault: str = None
198
199def formatDifference(diff):
200 '''Format a Difference for display, returning a list of lines.'''
201 # Default mismatch
202 if diff.diffType == DiffType.DEFAULT_MISMATCH:
203 return [
204 f' {diff.node}.{diff.port} ({diff.valueType}):',
205 f' Signature: {diff.signature}',
206 f' Spec default: {diff.specDefault}',
207 f' Data library default: {diff.libDefault}',
208 ]
209
210 # Different input sets
211 if diff.diffType == DiffType.SIGNATURE_DIFFERENT_INPUTS:
212 lines = [f' {diff.node}: {diff.signature}']
213 if diff.extraInLib:
214 extraStr = ', '.join(f'{n}:{t}' for n, t in diff.extraInLib)
215 lines.append(f' Extra in library: {extraStr}')
216 if diff.extraInSpec:
217 extraStr = ', '.join(f'{n}:{t}' for n, t in diff.extraInSpec)
218 lines.append(f' Extra in spec: {extraStr}')
219 return lines
220
221 # Signature mismatch (missing in spec or library)
222 if diff.signature:
223 return [f' {diff.node}: {diff.signature}']
224
225 # Spec validation error with port
226 if diff.port:
227 return [f' {diff.node}.{diff.port}']
228
229 # Node-level difference or simple spec validation error
230 return [f' {diff.node}']
231
232
233# -----------------------------------------------------------------------------

Callers 1

printDifferencesFunction · 0.85

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected