MCPcopy
hub / github.com/Comfy-Org/ComfyUI-Manager / gen_json

Function gen_json

scanner.py:623–768  ·  view source on GitHub ↗

Generate extension-node-map.json from scanned node information Args: node_info (dict): Repository metadata mapping scan_only_mode (bool): If True, exclude metadata from output

(node_info, scan_only_mode=False)

Source from the content-addressed store, hash-verified

621
622
623def gen_json(node_info, scan_only_mode=False):
624 """
625 Generate extension-node-map.json from scanned node information
626
627 Args:
628 node_info (dict): Repository metadata mapping
629 scan_only_mode (bool): If True, exclude metadata from output
630 """
631 # scan from .py file
632 node_files, node_dirs = get_nodes(temp_dir)
633
634 comfyui_path = os.path.abspath(os.path.join(temp_dir, "ComfyUI"))
635 # Only reorder if ComfyUI exists in the list
636 if comfyui_path in node_dirs:
637 node_dirs.remove(comfyui_path)
638 node_dirs = [comfyui_path] + node_dirs
639
640 data = {}
641 for dirname in node_dirs:
642 py_files = get_py_file_paths(dirname)
643 metadata = {}
644
645 nodes = set()
646 for py in py_files:
647 nodes_in_file, metadata_in_file = scan_in_file(py, dirname == "ComfyUI")
648 nodes.update(nodes_in_file)
649 # Include metadata from .py files in both modes
650 metadata.update(metadata_in_file)
651
652 dirname = os.path.basename(dirname)
653
654 if 'Jovimetrix' in dirname:
655 pass
656
657 if len(nodes) > 0 or (dirname in node_info and node_info[dirname][3] is not None):
658 nodes = list(nodes)
659 nodes.sort()
660
661 if dirname in node_info:
662 git_url, title, preemptions, node_pattern = node_info[dirname]
663
664 # Conditionally add metadata based on mode
665 if not scan_only_mode:
666 # Standard mode: include all metadata
667 metadata['title_aux'] = title
668
669 if preemptions is not None:
670 metadata['preemptions'] = preemptions
671
672 if node_pattern is not None:
673 metadata['nodename_pattern'] = node_pattern
674 # Scan-only mode: metadata remains empty
675
676 data[git_url] = (nodes, metadata)
677 else:
678 # Scan-only mode: Repository not in node_info (expected behavior)
679 # Construct URL from dirname (author_repo format)
680 if '_' in dirname:

Callers 1

scanner.pyFile · 0.85

Calls 6

get_nodesFunction · 0.85
get_py_file_pathsFunction · 0.85
scan_in_fileFunction · 0.85
removeMethod · 0.80
updateMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected