Skip to content

Commit 559af0c

Browse files
authored
Merge pull request #45 from mmartial/main
2 parents 185d2d1 + 56484f4 commit 559af0c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

mikey_nodes.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
from tqdm import tqdm
2525

2626
import folder_paths
27-
file_path = os.path.join(folder_paths.base_path, 'comfy_extras/nodes_clip_sdxl.py')
27+
file_path = os.path.join(os.path.dirname(folder_paths.__file__), 'comfy_extras/nodes_clip_sdxl.py')
2828
module_name = "nodes_clip_sdxl"
2929
spec = importlib.util.spec_from_file_location(module_name, file_path)
3030
module = importlib.util.module_from_spec(spec)
3131
sys.modules[module_name] = module
3232
spec.loader.exec_module(module)
3333
from nodes_clip_sdxl import CLIPTextEncodeSDXL, CLIPTextEncodeSDXLRefiner
34-
file_path = os.path.join(folder_paths.base_path, 'comfy_extras/nodes_upscale_model.py')
34+
file_path = os.path.join(os.path.dirname(folder_paths.__file__), 'comfy_extras/nodes_upscale_model.py')
3535
module_name = "nodes_upscale_model"
3636
spec = importlib.util.spec_from_file_location(module_name, file_path)
3737
module = importlib.util.module_from_spec(spec)
@@ -62,7 +62,7 @@ def calculate_file_hash(file_path):
6262

6363
def get_cached_file_hashes():
6464
# load the cached file hashes from the JSON file
65-
cache_file_path = os.path.join(folder_paths.base_path, 'file_hashes.json')
65+
cache_file_path = os.path.join(folder_paths.get_temp_directory(), 'file_hashes.json')
6666
if os.path.exists(cache_file_path):
6767
with open(cache_file_path, 'r') as f:
6868
return json.load(f)
@@ -85,7 +85,7 @@ def get_file_hash(file_path):
8585

8686
def cache_file_hash(file_path, file_hash):
8787
# update the cached file hashes dictionary and save to the JSON file
88-
cache_file_path = os.path.join(folder_paths.base_path, 'file_hashes.json')
88+
cache_file_path = os.path.join(folder_paths.get_temp_directory(), 'file_hashes.json')
8989
cached_file_hashes = get_cached_file_hashes()
9090
cached_file_hashes[os.path.basename(file_path)] = file_hash
9191
with open(cache_file_path, 'w') as f:
@@ -141,7 +141,7 @@ def read_ratios():
141141
ratio_sizes = list(data['ratios'].keys())
142142
ratio_dict = data['ratios']
143143
# user_styles.json
144-
user_styles_path = os.path.join(folder_paths.base_path, 'user_ratios.json')
144+
user_styles_path = os.path.join(folder_paths.get_user_directory(), 'user_ratios.json')
145145
# check if file exists
146146
if os.path.isfile(user_styles_path):
147147
# read json and update ratio_dict
@@ -160,7 +160,7 @@ def read_ratio_presets():
160160
ratio_presets = list(data['ratio_presets'].keys())
161161
ratio_preset_dict = data['ratio_presets']
162162
# user_ratio_presets.json
163-
user_ratio_presets_path = os.path.join(folder_paths.base_path, 'user_ratio_presets.json')
163+
user_ratio_presets_path = os.path.join(folder_paths.get_user_directory(), 'user_ratio_presets.json')
164164
# check if file exists
165165
if os.path.isfile(user_ratio_presets_path):
166166
# read json and update ratio_dict
@@ -198,7 +198,7 @@ def read_styles():
198198
pos_style[style] = data['styles'][style]['positive']
199199
neg_style[style] = data['styles'][style]['negative']
200200
# user_styles.json
201-
user_styles_path = os.path.join(folder_paths.base_path, 'user_styles.json')
201+
user_styles_path = os.path.join(folder_paths.get_user_directory(), 'user_styles.json')
202202
# check if file exists
203203
if os.path.isfile(user_styles_path):
204204
# read json and update pos_style and neg_style
@@ -211,7 +211,7 @@ def read_styles():
211211
return styles, pos_style, neg_style
212212

213213
#def read_ratio_presets():
214-
# file_path = os.path.join(folder_paths.base_path, 'user_ratio_presets.json')
214+
# file_path = os.path.join(folder_paths.get_user_directory(), 'user_ratio_presets.json')
215215
# if os.path.isfile(file_path):
216216
# with open(file_path, 'r') as file:
217217
# data = json.load(file)
@@ -222,7 +222,7 @@ def read_styles():
222222

223223
def find_and_replace_wildcards(prompt, offset_seed, debug=False):
224224
# wildcards use the __file_name__ syntax with optional |word_to_find
225-
wildcard_path = os.path.join(folder_paths.base_path, 'wildcards')
225+
wildcard_path = os.path.join(folder_paths.get_user_directory(), 'wildcards')
226226
wildcard_regex = r'((\d+)\$\$)?__(!|\+|-|\*)?((?:[^|_]+_)*[^|_]+)((?:\|[^|]+)*)__'
227227
# r'(\[(\d+)\$\$)?__((?:[^|_]+_)*[^|_]+)((?:\|[^|]+)*)__\]?'
228228
match_strings = []

0 commit comments

Comments
 (0)