From 337bee24aaf20a319520215e72428ff21a8a0af5 Mon Sep 17 00:00:00 2001 From: "kyj@bowong.ai" Date: Fri, 21 Mar 2025 16:54:10 +0800 Subject: [PATCH] =?UTF-8?q?ADD=20=E5=A2=9E=E5=8A=A0=E8=BF=9C=E7=A8=8B?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E7=BC=96=E7=A0=81=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __init__.py | 8 +++++--- nodes/text.py | 22 +++++++++++++++++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/__init__.py b/__init__.py index f4b0af7..a1edd01 100644 --- a/__init__.py +++ b/__init__.py @@ -1,4 +1,4 @@ -from .nodes.text import LoadText +from .nodes.text import * from .nodes.traverse_folder import TraverseFolder from .nodes.unload_all_models import UnloadAllModels from .nodes.string_empty_judgement import StringEmptyJudgement @@ -24,7 +24,8 @@ NODE_CLASS_MAPPINGS = { "StringEmptyJudgement": StringEmptyJudgement, "unloadAllModels": UnloadAllModels, "TraverseFolder": TraverseFolder, - "LoadTextCustom": LoadText + "LoadTextCustom": LoadTextLocal, + "LoadTextCustomOnline": LoadTextOnline } # A dictionary that contains the friendly/humanly readable titles for the nodes @@ -40,5 +41,6 @@ NODE_DISPLAY_NAME_MAPPINGS = { "StringEmptyJudgement": "字符串是否为空", "unloadAllModels": "卸载所有已加载模型", "TraverseFolder": "遍历文件夹", - "LoadTextCustom": "读取文本文件" + "LoadTextCustom": "读取文本文件(本地)", + "LoadTextCustomOnline": "读取文本文件(线上)" } diff --git a/nodes/text.py b/nodes/text.py index 1facc7a..f2ef923 100644 --- a/nodes/text.py +++ b/nodes/text.py @@ -55,7 +55,7 @@ def get_file(root_dir, file): return full_path -class LoadText: +class LoadTextLocal: @classmethod def INPUT_TYPES(s): return { @@ -105,3 +105,23 @@ class LoadText: def load(self, root_dir, file, encoding): with open(get_file(root_dir,file), "r", encoding=encoding) as f: return (f.read(),) + +class LoadTextOnline: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "file_path":("STRING", {"default": "input/"}), + "encoding": ("STRING", {"default": "utf-8"}), + } + } + + RETURN_TYPES = ("STRING",) + + FUNCTION = "load" + + CATEGORY = "不忘科技-自定义节点🚩" + + def load(self, file_path, encoding): + with open(file_path, "r", encoding=encoding) as f: + return (f.read(),)