Exemple #1
0
 def start_scanning(self):
     if self.directories.has_iphoto_path():
         try:
             app("iPhoto")
         except ApplicationNotFoundError:
             self.view.show_message(tr("The iPhoto application couldn't be found."))
             return
     DupeGuruBase.start_scanning(self)
Exemple #2
0
 def start_scanning(self):
     if self.directories.has_iphoto_path():
         try:
             app('iPhoto')
         except ApplicationNotFoundError:
             self.view.show_message(
                 tr("The iPhoto application couldn't be found."))
             return
     DupeGuruBase.start_scanning(self)
Exemple #3
0
 def _job_completed(self, jobid):
     DupeGuruBase._job_completed(self, jobid)
     if jobid == JobType.Load:
         if hasattr(self, "path2iphoto"):
             del self.path2iphoto
         if hasattr(self, "path2aperture"):
             del self.path2aperture
     if jobid == JobType.Delete and self.deleted_aperture_photos:
         msg = tr('Deleted Aperture photos were sent to a project called "dupeGuru Trash".')
         self.view.show_message(msg)
Exemple #4
0
 def _job_completed(self, jobid, exc):
     DupeGuruBase._job_completed(self, jobid, exc)
     if jobid == JobType.Load:
         if hasattr(self, 'path2iphoto'):
             del self.path2iphoto
         if hasattr(self, 'path2aperture'):
             del self.path2aperture
     if jobid == JobType.Delete and self.deleted_aperture_photos:
         msg = tr("Deleted Aperture photos were sent to a project called \"dupeGuru Trash\".")
         self.view.show_message(msg)
Exemple #5
0
 def _job_completed(self, jobid):
     DupeGuruBase._job_completed(self, jobid)
     if jobid == JobType.Load:
         if hasattr(self, 'path2iphoto'):
             del self.path2iphoto
         if hasattr(self, 'path2aperture'):
             del self.path2aperture
     if jobid == JobType.Delete and self.deleted_aperture_photos:
         msg = tr(
             "Deleted Aperture photos were sent to a project called \"dupeGuru Trash\"."
         )
         self.view.show_message(msg)
Exemple #6
0
 def _do_delete_dupe(self, dupe, *args):
     if isinstance(dupe, IPhoto):
         try:
             a = app('iPhoto')
             album = a.photo_library_album()
             if album is None:
                 msg = "There are communication problems with iPhoto. Try opening iPhoto first, it might solve it."
                 raise EnvironmentError(msg)
             [photo] = album.photos[its.image_path == str(dupe.path)]()
             a.remove(photo, timeout=0)
         except ValueError:
             msg = "Could not find photo '{}' in iPhoto Library".format(
                 str(dupe.path))
             raise EnvironmentError(msg)
         except (CommandError, RuntimeError) as e:
             raise EnvironmentError(str(e))
     if isinstance(dupe, AperturePhoto):
         try:
             a = app('Aperture')
             # I'm flying blind here. In my own test library, all photos are in an album with the
             # id "LibraryFolder", so I'm going to guess that it's the case at least most of the
             # time. As a safeguard, if we don't find any library with that id, we'll use the
             # first album.
             # Now, about deleting: All attempts I've made at sending photos to trash failed,
             # even with normal applescript. So, what we're going to do here is to create a
             # "dupeGuru Trash" project and tell the user to manually send those photos to trash.
             libraries = a.libraries()
             library = first(l for l in libraries
                             if l.id == 'LibraryFolder')
             if library is None:
                 library = libraries[0]
             trash_project = a.projects["dupeGuru Trash"]
             if trash_project.exists():
                 trash_project = trash_project()
             else:
                 trash_project = library.make(
                     new=k.project,
                     with_properties={k.name: "dupeGuru Trash"})
             [photo] = library.image_versions[its.id == dupe.db_id]()
             photo.move(to=trash_project)
         except (IndexError, ValueError):
             msg = "Could not find photo '{}' in Aperture Library".format(
                 str(dupe.path))
             raise EnvironmentError(msg)
         except (CommandError, RuntimeError) as e:
             raise EnvironmentError(str(e))
     else:
         DupeGuruBase._do_delete_dupe(self, dupe, *args)
Exemple #7
0
 def _do_delete_dupe(self, dupe, *args):
     if isinstance(dupe, IPhoto):
         try:
             a = app("iPhoto")
             album = a.photo_library_album()
             if album is None:
                 msg = "There are communication problems with iPhoto. Try opening iPhoto first, it might solve it."
                 raise EnvironmentError(msg)
             [photo] = album.photos[its.image_path == str(dupe.path)]()
             a.remove(photo, timeout=0)
         except ValueError:
             msg = "Could not find photo '{}' in iPhoto Library".format(str(dupe.path))
             raise EnvironmentError(msg)
         except (CommandError, RuntimeError) as e:
             raise EnvironmentError(str(e))
     if isinstance(dupe, AperturePhoto):
         try:
             a = app("Aperture")
             # I'm flying blind here. In my own test library, all photos are in an album with the
             # id "LibraryFolder", so I'm going to guess that it's the case at least most of the
             # time. As a safeguard, if we don't find any library with that id, we'll use the
             # first album.
             # Now, about deleting: All attempts I've made at sending photos to trash failed,
             # even with normal applescript. So, what we're going to do here is to create a
             # "dupeGuru Trash" project and tell the user to manually send those photos to trash.
             libraries = a.libraries()
             library = first(l for l in libraries if l.id == "LibraryFolder")
             if library is None:
                 library = libraries[0]
             trash_project = a.projects["dupeGuru Trash"]
             if trash_project.exists():
                 trash_project = trash_project()
             else:
                 trash_project = library.make(new=k.project, with_properties={k.name: "dupeGuru Trash"})
             [photo] = library.image_versions[its.id == dupe.db_id]()
             photo.move(to=trash_project)
         except (IndexError, ValueError):
             msg = "Could not find photo '{}' in Aperture Library".format(str(dupe.path))
             raise EnvironmentError(msg)
         except (CommandError, RuntimeError) as e:
             raise EnvironmentError(str(e))
     else:
         DupeGuruBase._do_delete_dupe(self, dupe, *args)
Exemple #8
0
 def _create_file(self, path):
     if (self.directories.iphoto_libpath is not None) and (path in self.directories.iphoto_libpath[:-1]):
         if not hasattr(self, "path2iphoto"):
             photos = get_iphoto_pictures(self.directories.iphoto_libpath)
             self.path2iphoto = {p.path: p for p in photos}
         return self.path2iphoto.get(path)
     if (self.directories.aperture_libpath is not None) and (path in self.directories.aperture_libpath[:-1]):
         if not hasattr(self, "path2aperture"):
             photos = get_aperture_pictures(self.directories.aperture_libpath)
             self.path2aperture = {p.path: p for p in photos}
         return self.path2aperture.get(path)
     return DupeGuruBase._create_file(self, path)
Exemple #9
0
 def _create_file(self, path):
     if (self.directories.iphoto_libpath
             is not None) and (path
                               in self.directories.iphoto_libpath.parent()):
         if not hasattr(self, 'path2iphoto'):
             photos = get_iphoto_pictures(self.directories.iphoto_libpath)
             self.path2iphoto = {p.path: p for p in photos}
         return self.path2iphoto.get(path)
     if (self.directories.aperture_libpath is not None) and (
             path in self.directories.aperture_libpath.parent()):
         if not hasattr(self, 'path2aperture'):
             photos = get_aperture_pictures(
                 self.directories.aperture_libpath)
             self.path2aperture = {p.path: p for p in photos}
         return self.path2aperture.get(path)
     return DupeGuruBase._create_file(self, path)
Exemple #10
0
 def copy_or_move(self, dupe, copy, destination, dest_type):
     if isinstance(dupe, (IPhoto, AperturePhoto)):
         copy = True
     return DupeGuruBase.copy_or_move(self, dupe, copy, destination,
                                      dest_type)
Exemple #11
0
 def __init__(self, view):
     DupeGuruBase.__init__(self, view)
     self.directories = Directories()
Exemple #12
0
 def copy_or_move(self, dupe, copy, destination, dest_type):
     if isinstance(dupe, (IPhoto, AperturePhoto)):
         copy = True
     return DupeGuruBase.copy_or_move(self, dupe, copy, destination, dest_type)
Exemple #13
0
 def __init__(self, view, appdata):
     appdata = op.join(appdata, "dupeGuru Picture Edition")
     DupeGuruBase.__init__(self, view, appdata)
     self.directories = Directories()
Exemple #14
0
 def __init__(self, view):
     DupeGuruBase.__init__(self, view)
     self.directories = Directories()
Exemple #15
0
 def __init__(self, view):
     DupeGuruBase.__init__(self, view)
     self.fileclasses = [Photo]
Exemple #16
0
 def __init__(self, view, appdata):
     appdata = op.join(appdata, 'dupeGuru Picture Edition')
     DupeGuruBase.__init__(self, view, appdata)
     self.directories = Directories()