From cd957cdfdf11faa4350bee17127c4385c50e6f75 Mon Sep 17 00:00:00 2001 From: holonic Date: Wed, 5 Jun 2024 01:16:56 +0100 Subject: [PATCH] more expor --- __init__.py | 1 + nodes/export.py | 42 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/__init__.py b/__init__.py index 115b0b3..7c12d92 100644 --- a/__init__.py +++ b/__init__.py @@ -6,6 +6,7 @@ """ from .nodes.any import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS, AnyNode +from .nodes.export import AnyNodeExport __all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS'] diff --git a/nodes/export.py b/nodes/export.py index af7268a..6edde7e 100644 --- a/nodes/export.py +++ b/nodes/export.py @@ -1,5 +1,22 @@ +""" +AnyNode Export Module +--- +The idea is to refactor the AnyNode function into a node package +""" + +# Used to generate the full class code with integrated AnyNode function +EXPORT_SYSTEM_CLASS = """ +# Creating a ComfyUI Node Class +[[CONTROLINFO]] +""" + +# Used to rewrite the system maps in the main nodes.py file +EXPORT_SYSTEM_MAPS = """ +# Register the Node in the Package +""" + class AnyNodeExport: - """Exports your AnyNode so it can be a real boy!""" + """Exports your AnyNode so it can be a "real boy"!""" """ Needs the system prompt for exporting. Copy: @@ -15,9 +32,9 @@ class AnyNodeExport: return { "required": { "control": ("CTRL", {"forceInput": True}), - "package": ("STRING", {"default": "DefaultPack"}), - "name": ("STRING", {}), - "save_node": ("BOOLEAN", {"default": True}), + "package": ("STRING", {"default": "TestPack"}), + "name": ("STRING", {"default": "TestNode"}), + "save_node": ("BOOLEAN", {"default": False}), }, "optional": { "comment": ("STRING", { @@ -32,14 +49,23 @@ class AnyNodeExport: }, } - #INPUT_IS_LIST = True RETURN_TYPES = ("CTRL",) RETURN_NAMES = ("control",) FUNCTION = "export" OUTPUT_NODE = True - #OUTPUT_IS_LIST = (True,) CATEGORY = "utils" - - def export(self, control, text=None, unique_id=None, extra_pnginfo=None): + + def copy_core_files(self): pass + + def package_init(self, control, package_path, name, comment=None): + self.copy_core_files() + + def export(self, control, package=None, name=None, comment=None, save_node=False, prompt=None, unique_id=None, extra_pnginfo=None): + """Perform export if save_node is activated""" + if save_node: + package_path = f"custom_nodes/{package}/" + self.package_init(control, package_path, name, comment=comment) + + return (control, )