Example #1
0
 def copy_or_move(self, dupe, copy: bool, destination: str, dest_type: DestType):
     source_path = dupe.path
     location_path = first(p for p in self.directories if dupe.path in p)
     dest_path = Path(destination)
     if dest_type in {DestType.Relative, DestType.Absolute}:
         # no filename, no windows drive letter
         source_base = source_path.remove_drive_letter()[:-1]
         if dest_type == DestType.Relative:
             source_base = source_base[location_path:]
         dest_path = dest_path + source_base
     if not dest_path.exists():
         dest_path.makedirs()
     # Add filename to dest_path. For file move/copy, it's not required, but for folders, yes.
     dest_path = dest_path + source_path[-1]
     logging.debug("Copy/Move operation from '%s' to '%s'", source_path, dest_path)
     # Raises an EnvironmentError if there's a problem
     if copy:
         smart_copy(source_path, dest_path)
     else:
         smart_move(source_path, dest_path)
         self.clean_empty_dirs(source_path[:-1])
Example #2
0
 def copy_or_move(self, dupe, copy: bool, destination: str, dest_type: DestType):
     source_path = dupe.path
     location_path = first(p for p in self.directories if dupe.path in p)
     dest_path = Path(destination)
     if dest_type in {DestType.Relative, DestType.Absolute}:
         # no filename, no windows drive letter
         source_base = source_path.remove_drive_letter().parent()
         if dest_type == DestType.Relative:
             source_base = source_base[location_path:]
         dest_path = dest_path[source_base]
     if not dest_path.exists():
         dest_path.makedirs()
     # Add filename to dest_path. For file move/copy, it's not required, but for folders, yes.
     dest_path = dest_path[source_path.name]
     logging.debug("Copy/Move operation from '%s' to '%s'", source_path, dest_path)
     # Raises an EnvironmentError if there's a problem
     if copy:
         smart_copy(source_path, dest_path)
     else:
         smart_move(source_path, dest_path)
         self.clean_empty_dirs(source_path.parent())