diff --git a/imagepaste/operators.py b/imagepaste/operators.py index 2252f52..f8dd07c 100644 --- a/imagepaste/operators.py +++ b/imagepaste/operators.py @@ -198,10 +198,10 @@ def poll(_cls, context): ) -class IMAGEPASTE_OT_move_to_saved_directory(bpy.types.Operator): +class IMAGEPASTE_OT_move_to_save_directory(bpy.types.Operator): """Move images to a target directory""" - bl_idname = "imagepaste.move_to_saved_directory" + bl_idname = "imagepaste.move_to_save_directory" bl_label = "Move to Target Directory" bl_options = {"UNDO_GROUPED"} @@ -209,8 +209,8 @@ def __init__(self) -> None: from .helper import get_save_directory super().__init__() - self.saved_directory = get_save_directory() - self.orphaned_images = self.get_orphaned_images(self.saved_directory) + self.save_directory = get_save_directory() + self.orphaned_images = self.get_orphaned_images(self.save_directory) def execute(self, _context): from .image import Image @@ -221,7 +221,7 @@ def execute(self, _context): # Change the paths the images refers to with the new one for orphaned_image in self.orphaned_images: old_filepath = self.get_abspath(orphaned_image.filepath) - self.change_image_directory(orphaned_image, self.saved_directory) + self.change_image_directory(orphaned_image, self.save_directory) new_filepath = self.get_abspath(orphaned_image.filepath) # Also change in the dictionary if old_filepath in pasted_images: @@ -269,11 +269,11 @@ def get_abspaths(self, images: list[bpy.types.Image]) -> list[str]: """ return [self.get_abspath(image.filepath) for image in images] - def get_orphaned_images(self, saved_directory: str) -> list[bpy.types.Image]: + def get_orphaned_images(self, save_directory: str) -> list[bpy.types.Image]: """Get images that are not in the target directory. Args: - saved_directory (str): The target directory. + save_directory (str): The target directory. Returns: list[bpy.types.Image]: A list of orphaned images. @@ -296,7 +296,7 @@ def get_orphaned_images(self, saved_directory: str) -> list[bpy.types.Image]: if not image.filepath: continue filepath = self.get_abspath(image.filepath) - if dirname(filepath) == saved_directory: + if dirname(filepath) == save_directory: continue if preferences.image_type_to_move == "all_images": orphaned_images.append(image) @@ -307,18 +307,18 @@ def get_orphaned_images(self, saved_directory: str) -> list[bpy.types.Image]: return orphaned_images def change_image_directory( - self, orphaned_image: bpy.types.Image, saved_directory: str + self, orphaned_image: bpy.types.Image, save_directory: str ) -> None: """Change the directory of an orphaned image. Args: orphaned_image (bpy.types.Image): An orphaned image. - saved_directory (str): The target directory. + save_directory (str): The target directory. """ from os.path import join from shutil import copyfile - new_filepath = join(saved_directory, bpy.path.basename(orphaned_image.filepath)) + new_filepath = join(save_directory, bpy.path.basename(orphaned_image.filepath)) copyfile(bpy.path.abspath(orphaned_image.filepath), new_filepath) orphaned_image.filepath = new_filepath orphaned_image.reload() @@ -331,7 +331,7 @@ def change_image_directory( IMAGEPASTE_OT_shadereditor_paste, IMAGEPASTE_OT_view3d_paste_plane, IMAGEPASTE_OT_view3d_paste_reference, - IMAGEPASTE_OT_move_to_saved_directory, + IMAGEPASTE_OT_move_to_save_directory, ) diff --git a/imagepaste/preferences.py b/imagepaste/preferences.py index dba2253..51b2b93 100644 --- a/imagepaste/preferences.py +++ b/imagepaste/preferences.py @@ -234,8 +234,8 @@ def view3d_paste_reference_imageaddmenu_draw(self, _context): @bpy.app.handlers.persistent -def move_to_saved_directory_handler(self, _context): - bpy.ops.imagepaste.move_to_saved_directory("INVOKE_DEFAULT") +def move_to_save_directory_handler(self, _context): + bpy.ops.imagepaste.move_to_save_directory("INVOKE_DEFAULT") addon_keymaps = [] @@ -250,7 +250,7 @@ def register(): bpy.types.NODE_MT_context_menu.append(shadereditor_paste_contextmenu_draw) bpy.types.VIEW3D_MT_image_add.append(view3d_paste_plane_imageaddmenu_draw) bpy.types.VIEW3D_MT_image_add.append(view3d_paste_reference_imageaddmenu_draw) - bpy.app.handlers.save_post.append(move_to_saved_directory_handler) + bpy.app.handlers.save_post.append(move_to_save_directory_handler) kc = bpy.context.window_manager.keyconfigs.addon @@ -322,7 +322,7 @@ def unregister(): km.keymap_items.remove(kmi) addon_keymaps.clear() - bpy.app.handlers.save_post.remove(move_to_saved_directory_handler) + bpy.app.handlers.save_post.remove(move_to_save_directory_handler) bpy.types.VIEW3D_MT_image_add.remove(view3d_paste_reference_imageaddmenu_draw) bpy.types.VIEW3D_MT_image_add.remove(view3d_paste_plane_imageaddmenu_draw) bpy.types.NODE_MT_context_menu.remove(shadereditor_paste_contextmenu_draw)