def __init__(self, view, appdata): appdata = op.join(appdata, 'dupeGuru Music Edition') DupeGuruBase.__init__(self, view, appdata) # Use fileclasses set in DupeGuruBase.__init__() self.directories = Directories( fileclasses=self.directories.fileclasses) self.dead_tracks = []
def start_scanning(self): if self.directories.has_itunes_path(): try: app(ITUNES, terms=tunes) except ApplicationNotFoundError: self.view.show_message(tr("The iTunes application couldn't be found.")) return DupeGuruBase.start_scanning(self)
def _create_file(self, path): if (self.directories.itunes_libpath is not None) and (path in self.directories.itunes_libpath.parent()): if not hasattr(self, 'itunes_songs'): songs = get_itunes_songs(self.directories.itunes_libpath) self.itunes_songs = {song.path: song for song in songs} if path in self.itunes_songs: return self.itunes_songs[path] else: pass # We'll return the default file type, as per the last line of this method return DupeGuruBase._create_file(self, path)
def _job_completed(self, jobid, exc): if (jobid in {JobType.RemoveDeadTracks, JobType.ScanDeadTracks}) and (exc is not None): msg = tr("There were communication problems with iTunes. The operation couldn't be completed.") self.view.show_message(msg) return True if jobid == JobType.ScanDeadTracks: dead_tracks_count = len(self.dead_tracks) if dead_tracks_count > 0: msg = tr("Your iTunes Library contains %d dead tracks ready to be removed. Continue?") if self.view.ask_yes_no(msg % dead_tracks_count): self.remove_dead_tracks() else: msg = tr("You have no dead tracks in your iTunes Library") self.view.show_message(msg) if jobid == JobType.Load: if hasattr(self, 'itunes_songs'): # If we load another file, we want a refresh song list del self.itunes_songs DupeGuruBase._job_completed(self, jobid, exc)
def _job_completed(self, jobid): # XXX Just before release, I'm realizing that this piece of code below is why I was passing # job exception as an argument to _job_completed(). I have to comment it for now. It's not # the end of the world, but I should find an elegant solution to this at some point. # if (jobid in {JobType.RemoveDeadTracks, JobType.ScanDeadTracks}) and (exc is not None): # msg = tr("There were communication problems with iTunes. The operation couldn't be completed.") # self.view.show_message(msg) # return True if jobid == JobType.ScanDeadTracks: dead_tracks_count = len(self.dead_tracks) if dead_tracks_count > 0: msg = tr("Your iTunes Library contains %d dead tracks ready to be removed. Continue?") if self.view.ask_yes_no(msg % dead_tracks_count): self.remove_dead_tracks() else: msg = tr("You have no dead tracks in your iTunes Library") self.view.show_message(msg) if jobid == JobType.Load: if hasattr(self, 'itunes_songs'): # If we load another file, we want a refresh song list del self.itunes_songs DupeGuruBase._job_completed(self, jobid)
def copy_or_move(self, dupe, copy, destination, dest_type): if isinstance(dupe, ITunesSong): copy = True return DupeGuruBase.copy_or_move(self, dupe, copy, destination, dest_type)
def _do_delete_dupe(self, dupe, *args): if isinstance(dupe, ITunesSong): dupe.remove_from_library() DupeGuruBase._do_delete_dupe(self, dupe, *args)
def __init__(self, view): DupeGuruBase.__init__(self, view) # Use fileclasses set in DupeGuruBase.__init__() self.directories = Directories(fileclasses=self.directories.fileclasses) self.dead_tracks = []
def __init__(self, view, appdata): appdata = op.join(appdata, 'dupeGuru Music Edition') DupeGuruBase.__init__(self, view, appdata) # Use fileclasses set in DupeGuruBase.__init__() self.directories = Directories(fileclasses=self.directories.fileclasses) self.dead_tracks = []