2424from tqdm import tqdm
2525
2626import 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' )
2828module_name = "nodes_clip_sdxl"
2929spec = importlib .util .spec_from_file_location (module_name , file_path )
3030module = importlib .util .module_from_spec (spec )
3131sys .modules [module_name ] = module
3232spec .loader .exec_module (module )
3333from 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' )
3535module_name = "nodes_upscale_model"
3636spec = importlib .util .spec_from_file_location (module_name , file_path )
3737module = importlib .util .module_from_spec (spec )
@@ -62,7 +62,7 @@ def calculate_file_hash(file_path):
6262
6363def 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
8686def 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
223223def 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