def __invoke(self, librarian, event, *args): args = list(args) if args and args[0]: if isinstance(args[0], dict): args[0] = SongWrapper(args[0]) elif isinstance(args[0], (set, list)): args[0] = ListWrapper(args[0]) for plugin in list(self.__plugins.values()): method_name = 'plugin_on_' + event.replace('-', '_') handler = getattr(plugin, method_name, None) def overridden(obj, name): return name in type(obj).__dict__ if overridden(plugin, method_name): try: handler(*args) except Exception: print_e("Error during %s on %s" % (method_name, type(plugin))) errorhook() if event not in ["removed", "changed"] and args: from quodlibet import app songs = args[0] if not isinstance(songs, (set, list)): songs = [songs] songs = filter(None, songs) check_wrapper_changed(librarian, app.window, songs)
def __invoke(self, librarian, event, *args): args = list(args) if args and args[0]: if isinstance(args[0], dict): args[0] = SongWrapper(args[0]) elif isinstance(args[0], (set, list)): args[0] = ListWrapper(args[0]) for plugin in itervalues(self.__plugins): method_name = 'plugin_on_' + event.replace('-', '_') handler = getattr(plugin, method_name, None) def overridden(obj, name): return name in type(obj).__dict__ if overridden(plugin, method_name): try: handler(*args) except Exception: print_e("Error during %s on %s" % (method_name, type(plugin))) util.print_exc() if event not in ["removed", "changed"] and args: from quodlibet import app songs = args[0] if not isinstance(songs, (set, list)): songs = [songs] songs = filter(None, songs) check_wrapper_changed(librarian, app.window, songs)
def __handle(self, plugin, library, parent, songs): if len(songs) == 0: return try: if len(songs) == 1 and callable(plugin.plugin_single_song): try: ret = plugin.plugin_single_song(songs[0]) except Exception: print_exc() else: if ret: return if callable(plugin.plugin_song): try: ret = map(plugin.plugin_song, songs) except Exception: print_exc() else: if max(ret): return if callable(plugin.plugin_songs): try: ret = plugin.plugin_songs(songs) except Exception: print_exc() else: if ret: return if max(map(callable,(plugin.plugin_single_album, plugin.plugin_album, plugin.plugin_albums))): albums = self.__get_albums(songs) if callable(plugin.plugin_single_album) and len(albums) == 1: try: ret = plugin.plugin_single_album(albums[0]) except Exception: print_exc() else: if ret: return if callable(plugin.plugin_album): try: ret = map(plugin.plugin_album, albums) except Exception: print_exc() else: if max(ret): return if callable(plugin.plugin_albums): try: ret = plugin.plugin_albums(albums) except Exception: print_exc() else: if ret: return finally: check_wrapper_changed(library, parent, filter(None, songs))
def __invoke(self, librarian, event, *args): args = list(args) if args and args[0]: if isinstance(args[0], dict): args[0] = SongWrapper(args[0]) elif isinstance(args[0], list): args[0] = ListWrapper(args[0]) for plugin in self.__plugins.itervalues(): handler = getattr(plugin, 'plugin_on_' + event, None) if handler is not None: try: handler(*args) except Exception: util.print_exc() if event not in ["removed", "changed"] and args: from quodlibet import app songs = args[0] if not isinstance(songs, list): songs = [songs] songs = filter(None, songs) check_wrapper_changed(librarian, app.window, songs)
def __invoke(self, librarian, event, *args): args = list(args) if args and args[0]: if isinstance(args[0], dict): args[0] = SongWrapper(args[0]) elif isinstance(args[0], (set, list)): args[0] = ListWrapper(args[0]) for plugin in self.__plugins.itervalues(): method_name = 'plugin_on_' + event.replace('-', '_') handler = getattr(plugin, method_name, None) if handler is not None: try: handler(*args) except Exception: util.print_exc() if event not in ["removed", "changed"] and args: from quodlibet import app songs = args[0] if not isinstance(songs, (set, list)): songs = [songs] songs = filter(None, songs) check_wrapper_changed(librarian, app.window, songs)
def __handle(self, item, plugin, library, songs, parent): if len(songs) == 0: return try: if len(songs) == 1 and callable(plugin.plugin_single_song): try: ret = plugin.plugin_single_song(songs[0]) except Exception: errorhook() else: if ret: return if callable(plugin.plugin_song): total = len(songs) if total > plugin.MAX_INVOCATIONS: if not self._confirm_multiple_songs( parent, plugin.PLUGIN_NAME, total): return try: ret = map(plugin.plugin_song, songs) except Exception: errorhook() else: if any(ret): return if callable(plugin.plugin_songs): try: ret = plugin.plugin_songs(songs) except Exception: errorhook() else: if ret: return if plugin.handles_albums: albums = self.__get_albums(songs) total = len(albums) if total > plugin.MAX_INVOCATIONS: if not self._confirm_multiple_albums( parent, plugin.PLUGIN_NAME, total): return if callable(plugin.plugin_single_album) and len(albums) == 1: try: ret = plugin.plugin_single_album(albums[0]) except Exception: errorhook() else: if ret: return if callable(plugin.plugin_album): try: ret = map(plugin.plugin_album, albums) except Exception: errorhook() else: if any(ret): return if callable(plugin.plugin_albums): try: ret = plugin.plugin_albums(albums) except Exception: errorhook() else: if ret: return finally: check_wrapper_changed(library, parent, filter(None, songs))
def __handle(self, plugin, library, parent, songs): if len(songs) == 0: return try: if len(songs) == 1 and callable(plugin.plugin_single_song): try: ret = plugin.plugin_single_song(songs[0]) except Exception: print_exc() else: if ret: return if callable(plugin.plugin_song): total = len(songs) if total > plugin.MAX_INVOCATIONS: msg = ngettext( "Are you sure you want to run " "the \"%s\" plugin on %d song?", "Are you sure you want to run " "the \"%s\" plugin on %d songs?", total) % (plugin.PLUGIN_ID, total) if not self.confirm_multiple(msg): return try: ret = map(plugin.plugin_song, songs) except Exception: print_exc() else: if max(ret): return if callable(plugin.plugin_songs): try: ret = plugin.plugin_songs(songs) except Exception: print_exc() else: if ret: return if plugin.handles_albums: albums = self.__get_albums(songs) total = len(albums) if total > plugin.MAX_INVOCATIONS: msg = ngettext( "Are you sure you want to run " "the \"%s\" plugin on %d album?", "Are you sure you want to run " "the \"%s\" plugin on %d albums?", total) % (plugin.PLUGIN_ID, total) if not self.confirm_multiple(msg): return if callable(plugin.plugin_single_album) and len(albums) == 1: try: ret = plugin.plugin_single_album(albums[0]) except Exception: print_exc() else: if ret: return if callable(plugin.plugin_album): try: ret = map(plugin.plugin_album, albums) except Exception: print_exc() else: if max(ret): return if callable(plugin.plugin_albums): try: ret = plugin.plugin_albums(albums) except Exception: print_exc() else: if ret: return finally: check_wrapper_changed(library, parent, filter(None, songs))
def plugin_finish(self): check_wrapper_changed(self.__library, self.plugin_window, self.__songs)
def __handle(self, item, plugin, library, songs, parent): if len(songs) == 0: return try: if len(songs) == 1 and callable(plugin.plugin_single_song): try: ret = plugin.plugin_single_song(songs[0]) except Exception: print_exc() else: if ret: return if callable(plugin.plugin_song): total = len(songs) if total > plugin.MAX_INVOCATIONS: if not self._confirm_multiple_songs( parent, plugin.PLUGIN_NAME, total): return try: ret = map(plugin.plugin_song, songs) except Exception: print_exc() else: if max(ret): return if callable(plugin.plugin_songs): try: ret = plugin.plugin_songs(songs) except Exception: print_exc() else: if ret: return if plugin.handles_albums: albums = self.__get_albums(songs) total = len(albums) if total > plugin.MAX_INVOCATIONS: if not self._confirm_multiple_albums( parent, plugin.PLUGIN_NAME, total): return if callable(plugin.plugin_single_album) and len(albums) == 1: try: ret = plugin.plugin_single_album(albums[0]) except Exception: print_exc() else: if ret: return if callable(plugin.plugin_album): try: ret = map(plugin.plugin_album, albums) except Exception: print_exc() else: if max(ret): return if callable(plugin.plugin_albums): try: ret = plugin.plugin_albums(albums) except Exception: print_exc() else: if ret: return finally: check_wrapper_changed(library, parent, filter(None, songs))