From 5992e91930b9e00c5afd687eb406f6795b0d198f Mon Sep 17 00:00:00 2001 From: aria1th <35677394+aria1th@users.noreply.github.com> Date: Fri, 23 May 2025 01:16:35 +0900 Subject: [PATCH] try optional dependency --- crypto.py | 11 ++++++++--- logic_gates.py | 6 +++--- nodes.py | 12 +++++++++--- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/crypto.py b/crypto.py index f01202d..d434959 100644 --- a/crypto.py +++ b/crypto.py @@ -4,9 +4,14 @@ from .imgio.converter import PILHandlingHodes from .autonode import node_wrapper, get_node_names_mappings, validate from PIL import Image -from Crypto.PublicKey import RSA -from Crypto.Cipher import AES, PKCS1_OAEP -from Crypto.Random import get_random_bytes +try: + from Crypto.PublicKey import RSA + from Crypto.Cipher import AES, PKCS1_OAEP + from Crypto.Random import get_random_bytes +except ImportError: + print("Crypto library not found. Please install pycryptodome.") + raise + import torch from base64 import b64encode, b64decode diff --git a/logic_gates.py b/logic_gates.py index c716dcb..a154639 100644 --- a/logic_gates.py +++ b/logic_gates.py @@ -385,9 +385,9 @@ class ReplaceString: def INPUT_TYPES(s): return { "required": { - "String": ("STRING", {"default": ""}), - "Regex": ("STRING", {"default": ""}), - "ReplaceWith": ("STRING", {"default": ""}), + "String": ("STRING", {"default": ""}), # input string + "Regex": ("STRING", {"default": ""}), # regex to search for + "ReplaceWith": ("STRING", {"default": ""}), # string to replace with } } FUNCTION = "replace" diff --git a/nodes.py b/nodes.py index 0144a31..22b281d 100644 --- a/nodes.py +++ b/nodes.py @@ -10,7 +10,7 @@ from .math_nodes import CLASS_MAPPINGS as MathMapping, CLASS_NAMES as MathNames from .io_node import CLASS_MAPPINGS as IOMapping, CLASS_NAMES as IONames from .auxilary import CLASS_MAPPINGS as AuxilaryMapping, CLASS_NAMES as AuxilaryNames from .external import CLASS_MAPPINGS as ExternalMapping, CLASS_NAMES as ExternalNames -from .crypto import CLASS_MAPPINGS as SecureMapping, CLASS_NAMES as SecureNames + NODE_CLASS_MAPPINGS = { @@ -22,7 +22,7 @@ NODE_CLASS_MAPPINGS.update(ConversionMapping) NODE_CLASS_MAPPINGS.update(MathMapping) NODE_CLASS_MAPPINGS.update(ExternalMapping) NODE_CLASS_MAPPINGS.update(AuxilaryMapping) -NODE_CLASS_MAPPINGS.update(SecureMapping) + NODE_DISPLAY_NAME_MAPPINGS = { @@ -35,7 +35,7 @@ NODE_DISPLAY_NAME_MAPPINGS.update(ConversionNames) NODE_DISPLAY_NAME_MAPPINGS.update(MathNames) NODE_DISPLAY_NAME_MAPPINGS.update(ExternalNames) NODE_DISPLAY_NAME_MAPPINGS.update(AuxilaryNames) -NODE_DISPLAY_NAME_MAPPINGS.update(SecureNames) + try: from .pystructure import CLASS_MAPPINGS as PyStructureMapping, CLASS_NAMES as PyStructureNames @@ -43,3 +43,9 @@ try: NODE_DISPLAY_NAME_MAPPINGS.update(PyStructureNames) except ImportError: pass +try: + from .crypto import CLASS_MAPPINGS as SecureMapping, CLASS_NAMES as SecureNames + NODE_CLASS_MAPPINGS.update(SecureMapping) + NODE_DISPLAY_NAME_MAPPINGS.update(SecureNames) +except ImportError: + pass \ No newline at end of file