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

Function main

python/Scripts/comparenodedefs.py:851–919  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

849# -----------------------------------------------------------------------------
850
851def main():
852 parser = argparse.ArgumentParser(
853 description="Compare node definitions between a specification Markdown document and a data library MaterialX document.")
854 parser.add_argument('--spec', dest='specFile',
855 help='Path to the specification Markdown document. Defaults to documents/Specification/MaterialX.StandardNodes.md')
856 parser.add_argument('--mtlx', dest='mtlxFile',
857 help='Path to the data library MaterialX document. Defaults to libraries/stdlib/stdlib_defs.mtlx')
858 parser.add_argument('--defaults', dest='compareDefaults', action='store_true',
859 help='Compare default values for inputs using MaterialX typed value comparison')
860 parser.add_argument('--listNodes', dest='listNodes', action='store_true',
861 help='List all nodes and their node signature counts')
862 opts = parser.parse_args()
863
864 # Determine file paths
865 repoRoot = Path(__file__).resolve().parent.parent.parent
866
867 specPath = Path(opts.specFile) if opts.specFile else repoRoot / 'documents' / 'Specification' / 'MaterialX.StandardNodes.md'
868 mtlxPath = Path(opts.mtlxFile) if opts.mtlxFile else repoRoot / 'libraries' / 'stdlib' / 'stdlib_defs.mtlx'
869
870 # Verify files exist
871 if not specPath.exists():
872 raise FileNotFoundError(f"Specification document not found: {specPath}")
873
874 if not mtlxPath.exists():
875 raise FileNotFoundError(f"MTLX document not found: {mtlxPath}")
876
877 print(f"Comparing:")
878 print(f" Specification: {specPath}")
879 print(f" Data Library: {mtlxPath}")
880
881 # Load standard libraries
882 stdlib = loadStandardLibraries()
883 geompropNames = buildGeompropNames(stdlib)
884
885 # Parse specification
886 print("\nParsing specification...")
887 specNodes, invalidEntries = parseSpecDocument(specPath, stdlib, geompropNames)
888 specSigCount = sum(len(n.signatures) for n in specNodes.values())
889 print(f" Found {len(specNodes)} nodes with {specSigCount} node signatures")
890 if invalidEntries:
891 print(f" Found {len(invalidEntries)} invalid specification entries")
892
893 # Load data library
894 print("Loading data library...")
895 libNodes, libDefaults = loadDataLibrary(mtlxPath)
896 libSigCount = sum(len(n.signatures) for n in libNodes.values())
897 print(f" Found {len(libNodes)} nodes with {libSigCount} node signatures")
898
899 # List nodes if requested
900 if opts.listNodes:
901 print("\nNodes in Specification:")
902 for name in sorted(specNodes.keys()):
903 node = specNodes[name]
904 print(f" {name}: {len(node.signatures)} signature(s)")
905
906 print("\nNodes in Data Library:")
907 for name in sorted(libNodes.keys()):
908 node = libNodes[name]

Callers 1

comparenodedefs.pyFile · 0.70

Calls 10

printFunction · 0.85
buildGeompropNamesFunction · 0.85
parseSpecDocumentFunction · 0.85
lenFunction · 0.85
loadDataLibraryFunction · 0.85
compareNodesFunction · 0.85
printDifferencesFunction · 0.85
existsMethod · 0.80
loadStandardLibrariesFunction · 0.70
resolveMethod · 0.45

Tested by

no test coverage detected