diff --git a/CheckpointLoaderSimpleText.py b/CheckpointLoaderSimpleText.py index 18a4f11..b5210f5 100644 --- a/CheckpointLoaderSimpleText.py +++ b/CheckpointLoaderSimpleText.py @@ -3,12 +3,13 @@ import comfy.sd from nodes import * import folder_paths import random -from .check_name import * import os if __name__ == os.path.splitext(os.path.basename(__file__))[0] : from ConsoleColor import print, console + from mypath import * else: from .ConsoleColor import print, console + from .mypath import * #print(__file__) #print(os.path.basename(__file__)) diff --git a/LoraLoaderTextRandom.py b/LoraLoaderTextRandom.py index 0713a0a..c320d14 100644 --- a/LoraLoaderTextRandom.py +++ b/LoraLoaderTextRandom.py @@ -3,7 +3,12 @@ import comfy.sd from nodes import * import folder_paths import random -from .check_name import * +if __name__ == os.path.splitext(os.path.basename(__file__))[0] : + from ConsoleColor import print, console + from mypath import * +else: + from .ConsoleColor import print, console + from .mypath import * class LoraLoaderTextRandom: @classmethod diff --git a/check_name.py b/check_name.py deleted file mode 100644 index 11f5a20..0000000 --- a/check_name.py +++ /dev/null @@ -1,25 +0,0 @@ -import os -from folder_paths import supported_ckpt_extensions,supported_pt_extensions -import folder_paths -import random - -def check_name(kind,name,supported_extensions): - for ext in supported_extensions: - if name.lower().endswith(ext): - path = folder_paths.get_full_path(kind, name) - if path is not None: - return path - - for ext in supported_extensions: - path = folder_paths.get_full_path(kind, name+ext) - if path is not None: - return path - -def check_name_ckpt(name): - return check_name("checkpoints",name,supported_ckpt_extensions) - -def check_name_pt(kind,name): - return check_name(kind,name,supported_pt_extensions) - -def name_split_choice(name): - return random.choice(name.split('|')) \ No newline at end of file diff --git a/mypath.py b/mypath.py index d43ef3f..6f8d19c 100644 --- a/mypath.py +++ b/mypath.py @@ -2,6 +2,9 @@ import sys import json import ast import os +from folder_paths import supported_ckpt_extensions,supported_pt_extensions +import folder_paths +import random if __name__ == os.path.splitext(os.path.basename(__file__))[0] : from ConsoleColor import print, console else: @@ -45,3 +48,26 @@ mainFile = os.path.abspath(sys.modules['__main__'].__file__) print("os.path.abspath(sys.modules\['__main__'].__file__) : " + mainFile ,style="bold CYAN") mainfolder = os.path.dirname(mainFile) print("os.path.dirname(mainFile) : " + mainfolder , style="bold CYAN") + + + +def check_name(kind,name,supported_extensions): + for ext in supported_extensions: + if name.lower().endswith(ext): + path = folder_paths.get_full_path(kind, name) + if path is not None: + return path + + for ext in supported_extensions: + path = folder_paths.get_full_path(kind, name+ext) + if path is not None: + return path + +def check_name_ckpt(name): + return check_name("checkpoints",name,supported_ckpt_extensions) + +def check_name_pt(kind,name): + return check_name(kind,name,supported_pt_extensions) + +def name_split_choice(name): + return random.choice(name.split('|')) \ No newline at end of file