def perform_for_photoset(self, photoset: Photoset, args: Namespace, world: World, group: Group) -> None: archive = world.archive multiplexer = Multiplexer(photoset.parts) primary_destination_tree = self.__get_biggest_tree( [multiplexer.justin, multiplexer.photoclub, multiplexer.closed]) primary_destination_name = primary_destination_tree.name primary_destination = archive.get_destination(primary_destination_name) final_path = archive.path / primary_destination_name assert primary_destination is not None if primary_destination.has_categories: primary_category_name = self.__get_biggest_tree( primary_destination_tree.subtrees).name final_path /= primary_category_name print( f"Moving {photoset.name} to {final_path.relative_to(archive.path)}" ) photoset.move(path=final_path) archive.refresh()
def perform(self, args: Namespace, world: World, group: Group) -> None: all_locations = world.all_locations paths = list(util.resolve_patterns(args.name)) if not paths: return path = paths[0] path_location = world.location_of_path(path) new_locations = [loc for loc in all_locations if loc != path_location] if len(new_locations) == 0: print("Current location is the only available.") # number of locations is global, photoset may have only one location -> other's can't be moved too return elif len(new_locations) == 1: selected_location = new_locations[0] else: selected_location = util.ask_for_choice( f"Where would you like to move {path.name}?", new_locations) for path in paths: from_location = world.location_of_path(path) photoset = Photoset(FolderTree(path)) try: ChecksRunner.instance().run(photoset, self.__prechecks) new_path = selected_location / photoset.path.parent.relative_to( from_location) photoset.move(new_path) except CheckFailedError as error: print(f"Unable to move {photoset.name}: {error}")
def transfer(self, photoset: Photoset): photoset.move(photoset.path.parent / self.__path)