add node scanner

This commit is contained in:
Dr.Lt.Data 2023-05-22 18:39:23 +09:00
parent 26dc378b88
commit 9894babccc
3 changed files with 966 additions and 1 deletions

3
.gitignore vendored
View File

@ -1 +1,2 @@
__pycache__/
__pycache__/
.tmp

816
extension-node-map.json Normal file
View File

@ -0,0 +1,816 @@
{
"https://github.com/pythongosssss/ComfyUI-WD14-Tagger": [
"WD14Tagger|pysssss"
],
"https://github.com/LEv145/images-grid-comfy-plugin": [
"LatentCombine",
"ImagesGridByColumns",
"ImagesGridByRows",
"ImageCombine",
"GridAnnotation"
],
"https://github.com/diontimmer/ComfyUI-Vextra-Nodes": [
"Prettify Prompt Using distilgpt2",
"Load Picture Index",
"Pixel Sort",
"Flatten Colors",
"Hue Rotation",
"Generate Noise Image",
"GlitchThis Effect",
"Apply Instagram Filter",
"Add Text To Image",
"Create Solid Color",
"Play Sound At Execution",
"Swap Color Mode",
"Prettify Prompt Using distilgpt2",
"Load Picture Index",
"Pixel Sort",
"Flatten Colors",
"Hue Rotation",
"Generate Noise Image",
"GlitchThis Effect",
"Apply Instagram Filter",
"Add Text To Image",
"Create Solid Color",
"Play Sound At Execution",
"Swap Color Mode"
],
"https://github.com/TinyTerra/ComfyUI_tinyterraNodes.git": [
"ttN pipeLoader",
"ttN pipeKSampler",
"ttN pipeIN",
"ttN pipeOUT",
"ttN pipeEDIT",
"ttN pipe2BASIC",
"ttN pipe2DETAILER",
"ttN text",
"ttN textDebug",
"ttN concat",
"ttN text3BOX_3WAYconcat",
"ttN text7BOX_concat",
"ttN imageOutput",
"ttN imageREMBG",
"ttN int",
"ttN float",
"ttN seed"
],
"https://github.com/omar92/ComfyUI-QualityOfLifeSuit_Omar92": [
"ChatGPT Simple _O",
"ChatGPT compact _O",
"load_openAI _O",
"Chat_Message _O",
"combine_chat_messages _O",
"Chat completion _O",
"create image _O",
"Edit_image _O",
"variation_image _O",
"LatentUpscaleFactor _O",
"LatentUpscaleFactorSimple _O",
"selectLatentFromBatch _O",
"VAEDecodeParallel _O",
"RandomNSP _O",
"ConcatRandomNSP_O",
"Concat Text _O",
"Trim Text _O",
"Replace Text _O",
"saveTextToFile _O",
"Text2Image _O",
"ImageScaleFactor _O",
"ImageScaleFactorSimple _O",
"Equation1param _O",
"Equation2params _O",
"floatToInt _O",
"intToFloat _O",
"floatToText _O",
"GetImage_(Width&Height) _O",
"GetLatent_(Width&Height) _O",
"debug messages_O",
"debug Completeion _O",
"Debug Text _O",
"Debug Text route _O",
"Note _O",
"Text _O",
"seed _O",
"int _O",
"float _O",
"ChatGPT _O",
"Chat_Message_fromString _O",
"compine_chat_messages _O",
"Chat_Completion _O",
"create_image _O",
"String _O",
"Debug String _O",
"concat Strings _O",
"trim String _O",
"replace String _O",
"replace String advanced _O",
"string2Image _O",
"CLIPStringEncode _O",
"LatentUpscaleMultiply",
"ChatGPT Simple _O",
"ChatGPT compact _O",
"load_openAI _O",
"Chat_Message _O",
"combine_chat_messages _O",
"Chat completion _O",
"create image _O",
"Edit_image _O",
"variation_image _O",
"LatentUpscaleFactor _O",
"LatentUpscaleFactorSimple _O",
"selectLatentFromBatch _O",
"VAEDecodeParallel _O",
"RandomNSP _O",
"ConcatRandomNSP_O",
"Concat Text _O",
"Trim Text _O",
"Replace Text _O",
"saveTextToFile _O",
"Text2Image _O",
"ImageScaleFactor _O",
"ImageScaleFactorSimple _O",
"Equation1param _O",
"Equation2params _O",
"floatToInt _O",
"intToFloat _O",
"floatToText _O",
"GetImage_(Width&Height) _O",
"GetLatent_(Width&Height) _O",
"debug messages_O",
"debug Completeion _O",
"Debug Text _O",
"Debug Text route _O",
"Note _O",
"Text _O",
"seed _O",
"int _O",
"float _O",
"ChatGPT _O",
"Chat_Message_fromString _O",
"compine_chat_messages _O",
"Chat_Completion _O",
"create_image _O",
"String _O",
"Debug String _O",
"concat Strings _O",
"trim String _O",
"replace String _O",
"replace String advanced _O",
"string2Image _O",
"CLIPStringEncode _O",
"LatentUpscaleMultiply"
],
"https://github.com/bvhari/ComfyUI_ImageProcessing": [
"BilateralFilter",
"UnsharpMask"
],
"https://github.com/BlenderNeko/ComfyUI_Noise": [
"BNK_NoisyLatentImage",
"BNK_DuplicateBatchIndex",
"BNK_SlerpLatent",
"BNK_GetSigma",
"BNK_InjectNoise",
"BNK_Unsampler"
],
"https://github.com/Kaharos94/ComfyUI-Saveaswebp": [
"Save_as_webp"
],
"https://github.com/BlenderNeko/ComfyUI_TiledKSampler": [
"BNK_TiledKSamplerAdvanced",
"BNK_TiledKSampler"
],
"https://github.com/sylym/comfy_vid2vid": [
"LoadImageSequence",
"LoadImageMaskSequence",
"VAEEncodeForInpaintSequence",
"DdimInversionSequence",
"SetLatentNoiseSequence",
"CheckpointLoaderSimpleSequence",
"LoraLoaderSequence",
"TrainUnetSequence",
"KSamplerSequence"
],
"https://github.com/LucianoCirino/efficiency-nodes-comfyui": [
"KSampler (Efficient)",
"Efficient Loader",
"XY Plot",
"Image Overlay",
"Evaluate Integers",
"Evaluate Strings"
],
"https://github.com/bvhari/ComfyUI_LatentToRGB": [
"LatentToRGB"
],
"https://github.com/SLAPaper/ComfyUI-Image-Selector": [
"ImageSelector",
"ImageDuplicator",
"LatentSelector",
"LatentDuplicator"
],
"https://github.com/ssitu/ComfyUI_UltimateSDUpscale": [
"UltimateSDUpscale"
],
"https://github.com/paulo-coronado/comfy_clip_blip_node": [
"CLIPTextEncodeBLIP",
"CLIPTextEncodeBLIP-2",
"Example"
],
"https://github.com/guoyk93/yk-node-suite-comfyui": [
"YKImagePadForOutpaint",
"YKMaskToImage"
],
"https://github.com/EllangoK/ComfyUI-post-processing-nodes": [
"ArithmeticBlend",
"AsciiArt",
"Blend",
"Blur",
"CannyEdgeMask",
"ChromaticAberration",
"ColorCorrect",
"ColorTint",
"Dissolve",
"DodgeAndBurn",
"FilmGrain",
"Glow",
"HSVThresholdMask",
"KuwaharaBlur",
"Parabolize",
"PencilSketch",
"PixelSort",
"Pixelize",
"Quantize",
"Sharpen",
"SineWave",
"Solarize",
"Vignette",
"Blur",
"KuwaharaBlur",
"HSVThresholdMask",
"PencilSketch",
"Vignette",
"DodgeAndBurn",
"Pixelize",
"ArithmeticBlend",
"AsciiArt",
"SineWave",
"ColorTint",
"Parabolize",
"ChromaticAberration",
"PixelSort",
"Solarize",
"Glow",
"ColorCorrect",
"Blend",
"Quantize",
"FilmGrain",
"Sharpen",
"Dissolve",
"CannyEdgeMask",
"Dither",
"KMeansQuantize",
"Blur",
"KuwaharaBlur",
"HSVThresholdMask",
"PencilSketch",
"Vignette",
"DodgeAndBurn",
"Pixelize",
"ArithmeticBlend",
"AsciiArt",
"SineWave",
"ColorTint",
"Parabolize",
"ChromaticAberration",
"PixelSort",
"Solarize",
"Glow",
"ColorCorrect",
"Blend",
"Quantize",
"FilmGrain",
"Sharpen",
"Dissolve",
"CannyEdgeMask",
"Dither",
"KMeansQuantize"
],
"https://github.com/szhublox/ambw_comfyui": [
"Auto Merge Block Weighted"
],
"https://github.com/BlenderNeko/ComfyUI_Cutoff": [
"BNK_CutoffBasePrompt",
"BNK_CutoffSetRegions",
"BNK_CutoffRegionsToConditioning",
"BNK_CutoffRegionsToConditioning_ADV"
],
"https://github.com/Derfuu/Derfuu_ComfyUI_ModdedNodes": [
"Float",
"Integer",
"Text",
"Text box",
"Float debug print",
"Int debug print",
"Tuple debug print",
"String debug print",
"Random",
"Tuple",
"Int to tuple",
"Tuple to floats",
"Tuple to ints",
"Tuple swap",
"Int to float",
"Ceil",
"Floor",
"Absolute value",
"Get latent size",
"Get image size",
"Sum",
"Subtract",
"Multiply",
"Divide",
"Power",
"Square root",
"Sinus",
"Cosines",
"Tangent",
"Latent Scale by ratio",
"Latent Scale to side",
"Image scale by ratio",
"Image scale to side",
"Conditioning area scale by ratio",
"ConditioningSetArea with tuples",
"LatentComposite with tuples",
"FloatDebugPrint_DF",
"IntDebugPrint_DF",
"TupleDebugPrint_DF",
"EmptyLatentImage_DF",
"LatentScale_Ratio_DF",
"LatentScale_Side_DF",
"ImageScale_Ratio_DF",
"ImageScale_Side_DF",
"ConditioningSetArea_DF",
"ConditioningSetAreaEXT_DF",
"RandomFloat_DF",
"Float2Tuple_DF",
"Tuple2Float_DF",
"Int2Float_DF",
"CeilNode_DF",
"FloorNode_DF",
"ABSNode_DF",
"GetLatentSize_DF",
"GetImageSize_DF",
"SumNode_DF",
"SubtractNode_DF",
"MultiplyNode_DF",
"DivideNode_DF",
"PowNode_DF",
"SqrtNode_DF",
"SinNode_DF",
"CosNode_DF",
"TanNode_DF",
"FloatNode_DF",
"IntegerNode_DF",
"StringNode_DF",
"TupleNode_DF",
"MultilineStringNode_DF",
"FloatDebugPrint_DF",
"IntDebugPrint_DF",
"TupleDebugPrint_DF",
"EmptyLatentImage_DF",
"LatentScale_Ratio_DF",
"LatentScale_Side_DF",
"ImageScale_Ratio_DF",
"ImageScale_Side_DF",
"ConditioningSetArea_DF",
"ConditioningSetAreaEXT_DF",
"RandomFloat_DF",
"Float2Tuple_DF",
"Tuple2Float_DF",
"Int2Float_DF",
"CeilNode_DF",
"FloorNode_DF",
"ABSNode_DF",
"GetLatentSize_DF",
"GetImageSize_DF",
"SumNode_DF",
"SubtractNode_DF",
"MultiplyNode_DF",
"DivideNode_DF",
"PowNode_DF",
"SqrtNode_DF",
"SinNode_DF",
"CosNode_DF",
"TanNode_DF",
"FloatNode_DF",
"IntegerNode_DF",
"StringNode_DF",
"TupleNode_DF",
"MultilineStringNode_DF",
"FloatDebugPrint_DF",
"IntDebugPrint_DF",
"TupleDebugPrint_DF",
"EmptyLatentImage_DF",
"LatentScale_Ratio_DF",
"LatentScale_Side_DF",
"ImageScale_Ratio_DF",
"ImageScale_Side_DF",
"ConditioningSetArea_DF",
"ConditioningSetAreaEXT_DF",
"RandomFloat_DF",
"Float2Tuple_DF",
"Tuple2Float_DF",
"Int2Float_DF",
"CeilNode_DF",
"FloorNode_DF",
"ABSNode_DF",
"GetLatentSize_DF",
"GetImageSize_DF",
"SumNode_DF",
"SubtractNode_DF",
"MultiplyNode_DF",
"DivideNode_DF",
"PowNode_DF",
"SqrtNode_DF",
"SinNode_DF",
"CosNode_DF",
"TanNode_DF",
"FloatNode_DF",
"IntegerNode_DF",
"StringNode_DF",
"TupleNode_DF",
"MultilineStringNode_DF"
],
"https://github.com/Jordach/comfy-plasma": [
"JDC_Plasma",
"JDC_RandNoise",
"JDC_GreyNoise",
"JDC_PinkNoise",
"JDC_BrownNoise",
"JDC_PlasmaSampler",
"JDC_PowerImage",
"JDC_Contrast"
],
"https://github.com/trojblue/trNodes": [
"trLayering",
"trColorCorrection",
"trRouter",
"trRouterLonger",
"JpgConvertNode"
],
"https://github.com/Fannovel16/comfy_video": [
"Video Frame Extractor",
"Save Frame To Folder",
"Simple Frame Folder To Video"
],
"https://github.com/WASasquatch/was-node-suite-comfyui": [
"Cache Node",
"Checkpoint Loader",
"Checkpoint Loader (Simple)",
"CLIPTextEncode (NSP)",
"Conditioning Input Switch",
"Constant Number",
"Create Grid Image",
"Create Morph Image",
"Create Morph Image from Path",
"Create Video from Path",
"CLIPSeg Masking",
"CLIPSeg Batch Masking",
"Convert Masks to Images",
"Debug Number to Console",
"Dictionary to Console",
"Diffusers Model Loader",
"Diffusers Hub Model Down-Loader",
"Latent Input Switch",
"Load Cache",
"Logic Boolean",
"Lora Loader",
"Image Analyze",
"Image Blank",
"Image Blend by Mask",
"Image Blend",
"Image Blending Mode",
"Image Bloom Filter",
"Image Canny Filter",
"Image Chromatic Aberration",
"Image Color Palette",
"Image Crop Face",
"Image Crop Location",
"Image Crop Square Location",
"Image Paste Face",
"Image Paste Crop",
"Image Paste Crop by Location",
"Image Pixelate",
"Image Dragan Photography Filter",
"Image Edge Detection Filter",
"Image Film Grain",
"Image Filter Adjustments",
"Image Flip",
"Image Gradient Map",
"Image Generate Gradient",
"Image High Pass Filter",
"Image History Loader",
"Image Input Switch",
"Image Levels Adjustment",
"Image Load",
"Image Median Filter",
"Image Mix RGB Channels",
"Image Monitor Effects Filter",
"Image Nova Filter",
"Image Padding",
"Image Perlin Noise Filter",
"Image Remove Background (Alpha)",
"Image Remove Color",
"Image Resize",
"Image Rotate",
"Image Save",
"Image Seamless Texture",
"Image Select Channel",
"Image Select Color",
"Image Shadows and Highlights",
"Image Size to Number",
"Image Stitch",
"Image Style Filter",
"Image Threshold",
"Image Tiled",
"Image Transpose",
"Image fDOF Filter",
"Image to Latent Mask",
"Image Voronoi Noise Filter",
"KSampler (WAS)",
"Latent Noise Injection",
"Latent Size to Number",
"Latent Upscale by Factor (WAS)",
"Load Image Batch",
"Load Text File",
"Load Lora",
"Masks Add",
"Masks Subtract",
"Mask Arbitrary Region",
"Mask Batch to Mask",
"Mask Ceiling Region",
"Mask Dilate Region",
"Mask Dominant Region",
"Mask Erode Region",
"Mask Fill Holes",
"Mask Floor Region",
"Mask Gaussian Region",
"Mask Invert",
"Mask Minority Region",
"Mask Smooth Region",
"Mask Threshold Region",
"Masks Combine Regions",
"Masks Combine Batch",
"MiDaS Depth Approximation",
"MiDaS Mask Image",
"Number Operation",
"Number to Float",
"Number Input Switch",
"Number Input Condition",
"Number Multiple Of",
"Number PI",
"Number to Int",
"Number to Seed",
"Number to String",
"Number to Text",
"Prompt Styles Selector",
"Random Number",
"Save Text File",
"Seed",
"Tensor Batch to Image",
"BLIP Analyze Image",
"SAM Model Loader",
"SAM Parameters",
"SAM Parameters Combine",
"SAM Image Mask",
"String to Text",
"Image Bounds",
"Inset Image Bounds",
"Bounded Image Blend",
"Bounded Image Blend with Mask",
"Bounded Image Crop",
"Bounded Image Crop with Mask",
"Text Dictionary Update",
"Text Add Tokens",
"Text Add Token by Input",
"Text Compare",
"Text Concatenate",
"Text File History Loader",
"Text Find and Replace by Dictionary",
"Text Find and Replace Input",
"Text Find and Replace",
"Text Input Switch",
"Text Multiline",
"Text Parse A1111 Embeddings",
"Text Parse Noodle Soup Prompts",
"Text Parse Tokens",
"Text Random Line",
"Text String",
"Text to Conditioning",
"Text to Console",
"Text to Number",
"Text to String",
"True Random.org Number Generator",
"unCLIP Checkpoint Loader",
"Upscale Model Loader",
"Write to GIF",
"Write to Video",
"Video Dump Frames"
],
"https://github.com/Davemane42/ComfyUI_Dave_CustomNode": [
"MultiLatentComposite",
"MultiAreaConditioning",
"ConditioningUpscale",
"ConditioningStretch",
"ABGRemover"
],
"https://github.com/YinBailiang/MergeBlockWeighted_fo_ComfyUI": [
"MergeBlockWeighted"
],
"https://github.com/Fannovel16/comfy_controlnet_preprocessors": [
"OpenposePreprocessor",
"MediaPipe-HandPosePreprocessor",
"SemSegPreprocessor",
"UniFormer-SemSegPreprocessor",
"OneFormer-COCO-SemSegPreprocessor",
"OneFormer-ADE20K-SemSegPreprocessor",
"MiDaS-DepthMapPreprocessor",
"MiDaS-NormalMapPreprocessor",
"LeReS-DepthMapPreprocessor",
"Zoe-DepthMapPreprocessor",
"BAE-NormalMapPreprocessor",
"MediaPipe-FaceMeshPreprocessor",
"ColorPreprocessor",
"TilePreprocessor",
"CannyEdgePreprocessor",
"M-LSDPreprocessor",
"HEDPreprocessor",
"ScribblePreprocessor",
"FakeScribblePreprocessor",
"BinaryPreprocessor",
"PiDiNetPreprocessor",
"LineArtPreprocessor",
"AnimeLineArtPreprocessor",
"Manga2Anime-LineArtPreprocessor",
"OpenposePreprocessor",
"MediaPipe-HandPosePreprocessor",
"SemSegPreprocessor",
"UniFormer-SemSegPreprocessor",
"OneFormer-COCO-SemSegPreprocessor",
"OneFormer-ADE20K-SemSegPreprocessor",
"MiDaS-DepthMapPreprocessor",
"MiDaS-NormalMapPreprocessor",
"LeReS-DepthMapPreprocessor",
"Zoe-DepthMapPreprocessor",
"BAE-NormalMapPreprocessor",
"MediaPipe-FaceMeshPreprocessor",
"ColorPreprocessor",
"TilePreprocessor",
"CannyEdgePreprocessor",
"M-LSDPreprocessor",
"HEDPreprocessor",
"ScribblePreprocessor",
"FakeScribblePreprocessor",
"BinaryPreprocessor",
"PiDiNetPreprocessor",
"LineArtPreprocessor",
"AnimeLineArtPreprocessor",
"Manga2Anime-LineArtPreprocessor"
],
"https://github.com/chenbaiyujason/sc-node-comfyui": [
"One Post to GPT",
"One GPT Builder",
"Combine GPT Prompt",
"Multiple Post to GPT",
"Prompt Preview",
"String to ASCII",
"SCSCCLIPTextEncode",
"Multiple Text String",
"Single Text String",
"Combine Text String",
"Builder Text String",
"SCSearch and Replace",
"SCText to Console"
],
"https://github.com/lilly1987/ComfyUI_node_Lilly": [
"LoraLoaderTextRandom",
"LoraLoaderText",
"VAELoaderDecode",
"CheckpointLoaderSimpleText",
"Random_Sampler"
],
"https://github.com/BlenderNeko/ComfyUI_ADV_CLIP_emb": [
"BNK_CLIPTextEncodeAdvanced",
"BNK_MixCLIPEmbeddings"
],
"https://github.com/flyingshutter/As_ComfyUI_CustomNodes": [
"MaskToImage_AS",
"ImageToMask_AS",
"LatentMix_AS",
"LatentAdd_AS",
"SaveLatent_AS",
"LoadLatent_AS",
"LatentToImages_AS",
"LatentMixMasked_As",
"ImageMixMasked_As",
"TextToImage_AS",
"BatchIndex_AS",
"MapRange_AS",
"Number_AS",
"Int2Any_AS",
"Number2Int_AS",
"Number2Float_AS",
"Math_AS",
"Increment_AS"
],
"https://github.com/BadCafeCode/masquerade-nodes-comfyui": [
"Mask By Text",
"Mask Morphology",
"Combine Masks",
"Unary Mask Op",
"Blur",
"Image To Mask",
"Mix Images By Mask",
"Mix Color By Mask",
"Mask To Region",
"Cut By Mask",
"Paste By Mask",
"Get Image Size",
"Change Channel Count",
"Constant Mask",
"Prune By Mask",
"Separate Mask Components",
"Create Rect Mask",
"Make Image Batch"
],
"https://github.com/ltdrdata/ComfyUI-Impact-Pack": [
"SAMLoader",
"MMDetDetectorProvider",
"CLIPSegDetectorProvider",
"ONNXDetectorProvider",
"BitwiseAndMaskForEach",
"SubtractMaskForEach",
"DetailerForEach",
"DetailerForEachDebug",
"DetailerForEachPipe",
"DetailerForEachDebugPipe",
"SAMDetectorCombined",
"FaceDetailer",
"FaceDetailerPipe",
"ToDetailerPipe",
"FromDetailerPipe",
"ToBasicPipe",
"FromBasicPipe",
"BasicPipeToDetailerPipe",
"DetailerPipeToBasicPipe",
"EditBasicPipe",
"EditDetailerPipe",
"LatentPixelScale",
"PixelKSampleUpscalerProvider",
"PixelKSampleUpscalerProviderPipe",
"IterativeLatentUpscale",
"IterativeImageUpscale",
"PixelTiledKSampleUpscalerProvider",
"PixelTiledKSampleUpscalerProviderPipe",
"TwoSamplersForMaskUpscalerProvider",
"TwoSamplersForMaskUpscalerProviderPipe",
"PixelKSampleHookCombine",
"DenoiseScheduleHookProvider",
"CfgScheduleHookProvider",
"BitwiseAndMask",
"SubtractMask",
"Segs & Mask",
"EmptySegs",
"MaskToSEGS",
"ToBinaryMask",
"BboxDetectorSEGS",
"SegmDetectorSEGS",
"ONNXDetectorSEGS",
"BboxDetectorCombined",
"SegmDetectorCombined",
"SegsToCombinedMask",
"KSamplerProvider",
"TwoSamplersForMask",
"TiledKSamplerProvider",
"PreviewBridge",
"MaskPainter",
"MMDetLoader",
"SegsMaskCombine",
"BboxDetectorForEach",
"SegmDetectorForEach"
],
"https://github.com/Jcd1230/rembg-comfyui-node": [
"Image Remove Background (rembg)"
],
"https://github.com/gamert/ComfyUI_tagger": [
"ImageTaggerDD",
"CLIPTextEncodeTaggerDD",
"LoadImage_Tagger",
"PromptDD"
],
"https://github.com/strimmlarn/ComfyUI_Strimmlarns_aesthetic_score": [
"CalculateAestheticScore",
"LoadAesteticModel",
"AesthetlcScoreSorter",
"ScoreToNumber"
]
}

148
scanner.py Normal file
View File

@ -0,0 +1,148 @@
import re
import os
import json
import sys
from git import Repo
def scan_in_file(filename):
with open(filename, "r") as file:
code = file.read()
pattern = r"NODE_CLASS_MAPPINGS\s*=\s*{([^}]*)}"
regex = re.compile(pattern, re.MULTILINE | re.DOTALL)
match = regex.search(code)
if match:
dict_text = match.group(1)
else:
return []
nodes = []
class_dict = {}
key_value_pairs = re.findall(r"\"([^\"]*)\"\s*:\s*([^,\n]*)", dict_text)
for key, value in key_value_pairs:
class_dict[key] = value.strip()
for key, value in class_dict.items():
nodes.append(key)
return nodes
def get_py_file_paths(dirname):
file_paths = []
for root, dirs, files in os.walk(dirname):
if ".git" in root or "__pycache__" in root:
continue
for file in files:
if file.endswith(".py"):
file_path = os.path.join(root, file)
file_paths.append(file_path)
for subdir in dirs:
subdir = os.path.join(dirname, subdir)
sub_files = get_py_file_paths(subdir)
file_paths.extend(sub_files)
return file_paths
def get_nodes(target_dir):
py_files = []
directories = []
for item in os.listdir(target_dir):
if ".git" in item or "__pycache__" in item:
continue
path = os.path.abspath(os.path.join(target_dir, item))
if os.path.isfile(path) and item.endswith(".py"):
py_files.append(path)
elif os.path.isdir(path):
directories.append(path)
return py_files, directories
def get_git_urls_from_json(json_file):
with open(json_file) as file:
data = json.load(file)
custom_nodes = data.get('custom_nodes', [])
git_clone_files = []
for node in custom_nodes:
if node.get('install_type') == 'git-clone':
files = node.get('files', [])
if files:
git_clone_files.append(files[0])
return git_clone_files
def clone_or_pull_git_repository(git_url):
repo_name = git_url.split("/")[-1].split(".")[0]
repo_dir = os.path.join(os.getcwd(), ".tmp", repo_name)
if os.path.exists(repo_dir):
try:
repo = Repo(repo_dir)
origin = repo.remote(name="origin")
origin.pull()
print(f"Pulling {repo_name}...")
except Exception as e:
print(f"Pulling {repo_name} failed: {e}")
else:
try:
repo = Repo.clone_from(git_url, repo_dir)
print(f"Cloning {repo_name}...")
except Exception as e:
print(f"Cloning {repo_name} failed: {e}")
def update_custom_nodes():
tmp_dir = os.path.join(os.getcwd(), ".tmp")
if not os.path.exists(tmp_dir):
os.makedirs(tmp_dir)
node_info = {}
git_urls = get_git_urls_from_json('custom-node-list.json')
for url in git_urls:
name = os.path.basename(url)
if name.endswith(".git"):
name = name[:-4]
node_info[name] = url
clone_or_pull_git_repository(url)
return node_info
def gen_json(node_info):
node_files, node_dirs = get_nodes(".tmp")
data = {}
for dirname in node_dirs:
py_files = get_py_file_paths(dirname)
nodes = []
for py in py_files:
nodes.extend(scan_in_file(py))
dirname = os.path.basename(dirname)
if nodes != []:
git_url = node_info[dirname]
data[git_url] = nodes
json_path = f"extension-node-map.json"
with open(json_path, "w") as file:
json.dump(data, file, indent=4)
node_info = update_custom_nodes()
gen_json(node_info)