From f8e63fb6f970feb62f49bcdde3698159d7951a54 Mon Sep 17 00:00:00 2001 From: SoyokaZZ Date: Sat, 18 Nov 2023 21:20:37 +0900 Subject: [PATCH] change --- .gitignore | 2 ++ README.md | 2 ++ __init__.py | 3 +++ modules/get_path.py | 52 +++++++++++++++++++++++++++++++++++++++++++++ setting.json | 3 +++ 5 files changed, 62 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 __init__.py create mode 100644 modules/get_path.py create mode 100644 setting.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6f5ced1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.vscode +__pycache__ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..10f9d1a --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# select_folder_path_easy +# select diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..013bcf3 --- /dev/null +++ b/__init__.py @@ -0,0 +1,3 @@ +from .modules.get_path import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS + +__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS'] \ No newline at end of file diff --git a/modules/get_path.py b/modules/get_path.py new file mode 100644 index 0000000..44c6752 --- /dev/null +++ b/modules/get_path.py @@ -0,0 +1,52 @@ +from datetime import datetime +import json +import os + +class SelectFolderPathEasy6321: + day_format = None + def __init__(self): + # 現在のスクリプトが存在するディレクトリのパス + current_directory = os.path.dirname(os.path.realpath(__file__)) + + # ひとつ上のディレクトリのパスを取得 + parent_directory = os.path.abspath(os.path.join(current_directory, os.pardir)) + with open(os.path.join(parent_directory, 'setting.json'),"r") as f: + json_dict = json.load(f) + self.day_format = json_dict["day_format"] + + @classmethod + def INPUT_TYPES(self): + return { + "required": { + "folder_name": ("STRING", { + "multiline": False, #True if you want the field to look like the one on the ClipTextEncode node + "default": "My_File" + }), + "file_name": ("STRING", { + "multiline": False, #True if you want the field to look like the one on the ClipTextEncode node + "default": "image" + }), + "time_format":("STRING",{ + "multiline": False, #True if you want the field to look like the one on the ClipTextEncode node + "default": self.day_format + }) + } + } + RETURN_TYPES = ("STRING",) + FUNCTION = "get_my_path" + CATEGORY = "umikaze" + + def get_my_path(self,folder_name,file_name,time_format): + # 今日の日付を取得 + today = datetime.today() + + # 日付を指定した形式の文字列に変換 + formatted_date = today.strftime(time_format) + return (f"{formatted_date}/{folder_name}/{file_name}",) + +NODE_CLASS_MAPPINGS = { + "SelectFolderPathEasy": SelectFolderPathEasy6321 +} +NODE_DISPLAY_NAME_MAPPINGS = { + "SelectFolderPathEasy": "Select Folder Path Easy" +} \ No newline at end of file diff --git a/setting.json b/setting.json new file mode 100644 index 0000000..0b86fc0 --- /dev/null +++ b/setting.json @@ -0,0 +1,3 @@ +{ + "day_format":"%Y-%m-%d" +} \ No newline at end of file