24
24
from tqdm import tqdm
25
25
26
26
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' )
28
28
module_name = "nodes_clip_sdxl"
29
29
spec = importlib .util .spec_from_file_location (module_name , file_path )
30
30
module = importlib .util .module_from_spec (spec )
31
31
sys .modules [module_name ] = module
32
32
spec .loader .exec_module (module )
33
33
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' )
35
35
module_name = "nodes_upscale_model"
36
36
spec = importlib .util .spec_from_file_location (module_name , file_path )
37
37
module = importlib .util .module_from_spec (spec )
@@ -62,7 +62,7 @@ def calculate_file_hash(file_path):
62
62
63
63
def get_cached_file_hashes ():
64
64
# 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' )
66
66
if os .path .exists (cache_file_path ):
67
67
with open (cache_file_path , 'r' ) as f :
68
68
return json .load (f )
@@ -85,7 +85,7 @@ def get_file_hash(file_path):
85
85
86
86
def cache_file_hash (file_path , file_hash ):
87
87
# 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' )
89
89
cached_file_hashes = get_cached_file_hashes ()
90
90
cached_file_hashes [os .path .basename (file_path )] = file_hash
91
91
with open (cache_file_path , 'w' ) as f :
@@ -141,7 +141,7 @@ def read_ratios():
141
141
ratio_sizes = list (data ['ratios' ].keys ())
142
142
ratio_dict = data ['ratios' ]
143
143
# 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' )
145
145
# check if file exists
146
146
if os .path .isfile (user_styles_path ):
147
147
# read json and update ratio_dict
@@ -160,7 +160,7 @@ def read_ratio_presets():
160
160
ratio_presets = list (data ['ratio_presets' ].keys ())
161
161
ratio_preset_dict = data ['ratio_presets' ]
162
162
# 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' )
164
164
# check if file exists
165
165
if os .path .isfile (user_ratio_presets_path ):
166
166
# read json and update ratio_dict
@@ -198,7 +198,7 @@ def read_styles():
198
198
pos_style [style ] = data ['styles' ][style ]['positive' ]
199
199
neg_style [style ] = data ['styles' ][style ]['negative' ]
200
200
# 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' )
202
202
# check if file exists
203
203
if os .path .isfile (user_styles_path ):
204
204
# read json and update pos_style and neg_style
@@ -211,7 +211,7 @@ def read_styles():
211
211
return styles , pos_style , neg_style
212
212
213
213
#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')
215
215
# if os.path.isfile(file_path):
216
216
# with open(file_path, 'r') as file:
217
217
# data = json.load(file)
@@ -222,7 +222,7 @@ def read_styles():
222
222
223
223
def find_and_replace_wildcards (prompt , offset_seed , debug = False ):
224
224
# 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' )
226
226
wildcard_regex = r'((\d+)\$\$)?__(!|\+|-|\*)?((?:[^|_]+_)*[^|_]+)((?:\|[^|]+)*)__'
227
227
# r'(\[(\d+)\$\$)?__((?:[^|_]+_)*[^|_]+)((?:\|[^|]+)*)__\]?'
228
228
match_strings = []
0 commit comments