@@ -253,8 +253,8 @@ def convert_paths_to_absolute(self, file_path, data):
253
253
# Optimized regex replacement
254
254
data = re .sub (path_regex , self .replace_string_to_absolute , data )
255
255
256
- except Exception as ex :
257
- log .error ("Error while converting relative paths to absolute paths: %s" % str ( ex ) )
256
+ except Exception :
257
+ log .error ("Error while converting relative paths to absolute paths" , exc_info = 1 )
258
258
259
259
return data
260
260
@@ -266,14 +266,16 @@ def replace_string_to_relative(self, match):
266
266
267
267
# Determine if thumbnail path is found
268
268
if info .THUMBNAIL_PATH in folder_path :
269
- # Convert path to relative thumbnail path
269
+ log .debug ("Generating relative thumbnail path to %s in %s" ,
270
+ file_path , folder_path )
270
271
new_path = os .path .join ("thumbnail" , file_path ).replace ("\\ " , "/" )
271
272
new_path = json .dumps (new_path , ensure_ascii = False )
272
273
return '"%s": %s' % (key , new_path )
273
274
274
275
# Determine if @transitions path is found
275
276
elif os .path .join (info .PATH , "transitions" ) in folder_path :
276
- # Yes, this is an OpenShot transition
277
+ log .debug ("Generating relative @transitions path for %s in %s" ,
278
+ file_path , folder_path )
277
279
folder_path , category_path = os .path .split (folder_path )
278
280
279
281
# Convert path to @transitions/ path
@@ -283,15 +285,15 @@ def replace_string_to_relative(self, match):
283
285
284
286
# Determine if @emojis path is found
285
287
elif os .path .join (info .PATH , "emojis" ) in folder_path :
286
- # Yes, this is an OpenShot emoji
287
- # Convert path to @emojis/ path
288
+ log . debug ( "Generating relative @emojis path for %s in %s" ,
289
+ file_path , folder_path )
288
290
new_path = os .path .join ("@emojis" , file_path ).replace ("\\ " , "/" )
289
291
new_path = json .dumps (new_path , ensure_ascii = False )
290
292
return '"%s": %s' % (key , new_path )
291
293
292
294
# Determine if @assets path is found
293
295
elif path_context ["new_project_assets" ] in folder_path :
294
- # Yes, this is an OpenShot transitions
296
+ log . debug ( "Replacing path to %s in %s" , file_path , folder_path )
295
297
folder_path = folder_path .replace (path_context ["new_project_assets" ], "@assets" )
296
298
297
299
# Convert path to @assets/ path
@@ -305,16 +307,19 @@ def replace_string_to_relative(self, match):
305
307
orig_abs_path = os .path .abspath (path )
306
308
307
309
# Determine windows drives that the project and file are on
308
- project_win_drive = os .path .splitdrive (get_app (). project . current_filepath )[0 ]
310
+ project_win_drive = os .path .splitdrive (path_context . get ( "new_project_folder" , "" ) )[0 ]
309
311
file_win_drive = os .path .splitdrive (path )[0 ]
310
312
if file_win_drive != project_win_drive :
313
+ log .debug ("Drive mismatch, not making path relative: %s" , orig_abs_path )
311
314
# If the file is on different drive. Don't abbreviate the path.
312
- return orig_abs_path
315
+ clean_path = orig_abs_path .replace ("\\ " , "/" )
316
+ clean_path = json .dumps (clean_path , ensure_ascii = False )
317
+ return f"{ key } : { clean_path } "
313
318
314
319
# Remove file from abs path
315
320
orig_abs_folder = os .path .dirname (orig_abs_path )
316
321
317
- # Calculate new relateive path
322
+ log . debug ( "Generating new relative path for %s" , orig_abs_path )
318
323
new_rel_path_folder = os .path .relpath (orig_abs_folder , path_context .get ("new_project_folder" , "" ))
319
324
new_rel_path = os .path .join (new_rel_path_folder , file_path ).replace ("\\ " , "/" )
320
325
new_rel_path = json .dumps (new_rel_path , ensure_ascii = False )
@@ -335,8 +340,8 @@ def convert_paths_to_relative(self, file_path, previous_path, data):
335
340
# Optimized regex replacement
336
341
data = re .sub (path_regex , self .replace_string_to_relative , data )
337
342
338
- except Exception as ex :
339
- log .error ("Error while converting absolute paths to relative paths: %s" % str ( ex ) )
343
+ except Exception :
344
+ log .error ("Error while converting absolute paths to relative paths" , exc_info = 1 )
340
345
341
346
return data
342
347
0 commit comments