From 7e9c30dfaf391ebb299381d6077644870c227853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 22 Apr 2012 19:53:48 +0200 Subject: [PATCH 01/15] fix bug 825205 - Keep/restore selected book, chapters and verses when changing the bible translation in advanced search --- openlp/plugins/bibles/lib/mediaitem.py | 31 +++++++++++++++++++++----- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index bca73fc70..c36ffa2bf 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -408,7 +408,7 @@ class BibleMediaItem(MediaManagerItem): self.plugin.appStartup() self.updateAutoCompleter() - def initialiseAdvancedBible(self, bible): + def initialiseAdvancedBible(self, bible, last_book_id=None): """ This initialises the given bible, which means that its book names and their chapter numbers is added to the combo boxes on the @@ -417,8 +417,12 @@ class BibleMediaItem(MediaManagerItem): ``bible`` The bible to initialise (unicode). + + ``last_book_id`` + The "book reference id" of the book which is choosen at the moment. + (int) """ - log.debug(u'initialiseAdvancedBible %s', bible) + log.debug(u'initialiseAdvancedBible %s, %s', bible, last_book_id) book_data = self.plugin.manager.get_books(bible) secondbible = unicode(self.advancedSecondComboBox.currentText()) if secondbible != u'': @@ -451,8 +455,19 @@ class BibleMediaItem(MediaManagerItem): row, QtCore.QVariant(book[u'book_reference_id'])) if first: first = False - self.initialiseChapterVerse(bible, book[u'name'], - book[u'book_reference_id']) + first_book = book + initialise_chapter_verse = True + if last_book_id and last_book_id == int(book[u'book_reference_id']): + index = self.advancedBookComboBox.findData( + QtCore.QVariant(book[u'book_reference_id'])) + if index == -1: + # Not Found. + index = 0 + self.advancedBookComboBox.setCurrentIndex(index) + initialise_chapter_verse = False + if initialise_chapter_verse: + self.initialiseChapterVerse(bible, first_book[u'name'], + first_book[u'book_reference_id']) def initialiseChapterVerse(self, bible, book, book_ref_id): log.debug(u'initialiseChapterVerse %s, %s, %s', bible, book, @@ -597,11 +612,15 @@ class BibleMediaItem(MediaManagerItem): QtCore.QSettings().setValue(self.settingsSection + u'/advanced bible', QtCore.QVariant(self.advancedVersionComboBox.currentText())) self.initialiseAdvancedBible( - unicode(self.advancedVersionComboBox.currentText())) + unicode(self.advancedVersionComboBox.currentText()), + self.advancedBookComboBox.itemData( + int(self.advancedBookComboBox.currentIndex()))) def onAdvancedSecondComboBox(self): self.initialiseAdvancedBible( - unicode(self.advancedVersionComboBox.currentText())) + unicode(self.advancedVersionComboBox.currentText()), + self.advancedBookComboBox.itemData( + int(self.advancedBookComboBox.currentIndex()))) def onAdvancedBookComboBox(self): item = int(self.advancedBookComboBox.currentIndex()) From 19ea43ead86413458e8d9970b124431ad0f480d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Mon, 23 Apr 2012 22:21:38 +0200 Subject: [PATCH 02/15] fixes --- openlp/plugins/bibles/lib/mediaitem.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index c36ffa2bf..8afb933dd 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -436,6 +436,7 @@ class BibleMediaItem(MediaManagerItem): book_data = book_data_temp self.advancedBookComboBox.clear() first = True + initialise_chapter_verse = False language_selection = self.plugin.manager.get_language_selection(bible) booknames = BibleStrings().Booknames for book in book_data: @@ -614,13 +615,13 @@ class BibleMediaItem(MediaManagerItem): self.initialiseAdvancedBible( unicode(self.advancedVersionComboBox.currentText()), self.advancedBookComboBox.itemData( - int(self.advancedBookComboBox.currentIndex()))) + int(self.advancedBookComboBox.currentIndex()))) def onAdvancedSecondComboBox(self): self.initialiseAdvancedBible( unicode(self.advancedVersionComboBox.currentText()), self.advancedBookComboBox.itemData( - int(self.advancedBookComboBox.currentIndex()))) + int(self.advancedBookComboBox.currentIndex()))) def onAdvancedBookComboBox(self): item = int(self.advancedBookComboBox.currentIndex()) From cbbfa8c23b69c7543d4e748b05b3b613ab8b6f98 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 28 Apr 2012 13:13:16 +0200 Subject: [PATCH 03/15] clean ups --- openlp/core/ui/media/__init__.py | 13 +-- openlp/core/ui/media/mediacontroller.py | 114 +++++++++++------------- openlp/core/ui/media/vlcplayer.py | 19 ++-- 3 files changed, 71 insertions(+), 75 deletions(-) diff --git a/openlp/core/ui/media/__init__.py b/openlp/core/ui/media/__init__.py index f4f4d98d0..ff6f7ae91 100644 --- a/openlp/core/ui/media/__init__.py +++ b/openlp/core/ui/media/__init__.py @@ -69,12 +69,13 @@ class MediaInfo(object): def get_media_players(): """ This method extract the configured media players and overridden player from - the settings + the settings. ``players_list`` - this is a python list with all active media players + Awith all active media players. + ``overridden_player`` - here an special media player is choosen for all media actions + Here an special media player is chosen for all media actions. """ log.debug(u'get_media_players') players = unicode(QtCore.QSettings().value(u'media/players').toString()) @@ -92,15 +93,17 @@ def get_media_players(): players_list = players.replace(u'[', u'').replace(u']', u'').split(u',') return players_list, overridden_player + def set_media_players(players_list, overridden_player=u'auto'): """ This method saves the configured media players and overridden player to the settings ``players_list`` - this is a python list with all active media players + A list with all active media players. + ``overridden_player`` - here an special media player is choosen for all media actions + Here an special media player is chosen for all media actions. """ log.debug(u'set_media_players') players = u','.join(players_list) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 7ccbd9245..bf5bcf808 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -84,10 +84,7 @@ class MediaController(object): def set_active_players(self): savedPlayers = get_media_players()[0] for player in self.mediaPlayers.keys(): - if player in savedPlayers: - self.mediaPlayers[player].isActive = True - else: - self.mediaPlayers[player].isActive = False + self.mediaPlayers[player].isActive = player in savedPlayers def register_controllers(self, controller): """ @@ -106,8 +103,8 @@ class MediaController(object): AppLocation.get_directory(AppLocation.AppDir), u'core', u'ui', u'media') for filename in os.listdir(controller_dir): - if filename.endswith(u'player.py') and \ - not filename == 'media_player.py': + if filename.endswith(u'player.py') and not \ + filename == 'media_player.py': path = os.path.join(controller_dir, filename) if os.path.isfile(path): modulename = u'openlp.core.ui.media.' + \ @@ -122,38 +119,36 @@ class MediaController(object): for controller_class in controller_classes: controller = controller_class(self) self.register_controllers(controller) - if self.mediaPlayers: - savedPlayers, overriddenPlayer = get_media_players() - invalidMediaPlayers = [mediaPlayer for mediaPlayer in savedPlayers \ - if not mediaPlayer in self.mediaPlayers or \ - not self.mediaPlayers[mediaPlayer].check_available()] - if len(invalidMediaPlayers) > 0: - for invalidPlayer in invalidMediaPlayers: - savedPlayers.remove(invalidPlayer) - set_media_players(savedPlayers, overriddenPlayer) - self.set_active_players() - return True - else: + if not self.mediaPlayers: return False + savedPlayers, overriddenPlayer = get_media_players() + invalidMediaPlayers = [mediaPlayer for mediaPlayer in savedPlayers + if not mediaPlayer in self.mediaPlayers or not + self.mediaPlayers[mediaPlayer].check_available()] + if invalidMediaPlayers: + for invalidPlayer in invalidMediaPlayers: + savedPlayers.remove(invalidPlayer) + set_media_players(savedPlayers, overriddenPlayer) + self.set_active_players() + return True def video_state(self): """ Check if there is a running media Player and do updating stuff (e.g. update the UI) """ - if len(self.curDisplayMediaPlayer.keys()) == 0: + if not self.curDisplayMediaPlayer.keys(): self.timer.stop() else: for display in self.curDisplayMediaPlayer.keys(): self.curDisplayMediaPlayer[display].resize(display) self.curDisplayMediaPlayer[display].update_ui(display) - if self.curDisplayMediaPlayer[display] \ - .state == MediaState.Playing: + if self.curDisplayMediaPlayer[display].state == \ + MediaState.Playing: return # no players are active anymore for display in self.curDisplayMediaPlayer.keys(): - if self.curDisplayMediaPlayer[display] \ - .state != MediaState.Paused: + if self.curDisplayMediaPlayer[display].state != MediaState.Paused: display.controller.seekSlider.setSliderPosition(0) self.timer.stop() @@ -333,8 +328,7 @@ class MediaController(object): 'Unsupported File'))) return False # dont care about actual theme, set a black background - if controller.isLive and ( \ - controller.media_info.is_background == False): + if controller.isLive and not controller.media_info.is_background: display.frame.evaluateJavaScript(u'show_video( \ "setBackBoard", null, null, null,"visible");') # now start playing @@ -395,7 +389,7 @@ class MediaController(object): """ Responds to the request to play a loaded video - ``msg`` + ``msg`` First element is the controller which should be used """ log.debug(u'video_play') @@ -497,15 +491,15 @@ class MediaController(object): First element is the boolean for Live indication """ isLive = msg[1] - if isLive: - controller = self.parent.liveController - for display in self.curDisplayMediaPlayer.keys(): - if display.controller == controller: - if self.curDisplayMediaPlayer[display] \ - .state == MediaState.Playing: - self.curDisplayMediaPlayer[display].pause(display) - self.curDisplayMediaPlayer[display] \ - .set_visible(display, False) + if not isLive: + return + controller = self.parent.liveController + for display in self.curDisplayMediaPlayer.keys(): + if display.controller != controller or \ + self.curDisplayMediaPlayer[display].state == MediaState.Playing: + continue + self.curDisplayMediaPlayer[display].pause(display) + self.curDisplayMediaPlayer[display].set_visible(display, False) def video_blank(self, msg): """ @@ -517,16 +511,16 @@ class MediaController(object): """ isLive = msg[1] hide_mode = msg[2] - if isLive: - Receiver.send_message(u'live_display_hide', hide_mode) - controller = self.parent.liveController - for display in self.curDisplayMediaPlayer.keys(): - if display.controller == controller: - if self.curDisplayMediaPlayer[display] \ - .state == MediaState.Playing: - self.curDisplayMediaPlayer[display].pause(display) - self.curDisplayMediaPlayer[display] \ - .set_visible(display, False) + if not isLive: + return + Receiver.send_message(u'live_display_hide', hide_mode) + controller = self.parent.liveController + for display in self.curDisplayMediaPlayer.keys(): + if display.controller != controller or \ + self.curDisplayMediaPlayer[display].state != MediaState.Playing: + continue + self.curDisplayMediaPlayer[display].pause(display) + self.curDisplayMediaPlayer[display].set_visible(display, False) def video_unblank(self, msg): """ @@ -538,19 +532,18 @@ class MediaController(object): """ Receiver.send_message(u'live_display_show') isLive = msg[1] - if isLive: - controller = self.parent.liveController - for display in self.curDisplayMediaPlayer.keys(): - if display.controller == controller: - if self.curDisplayMediaPlayer[display] \ - .state == MediaState.Paused: - if self.curDisplayMediaPlayer[display].play(display): - self.curDisplayMediaPlayer[display] \ - .set_visible(display, True) - # Start Timer for ui updates - if not self.timer.isActive(): - self.timer.start() - + if not isLive: + return + controller = self.parent.liveController + for display in self.curDisplayMediaPlayer.keys(): + if display.controller != controller or \ + self.curDisplayMediaPlayer[display].state != MediaState.Paused: + continue + if self.curDisplayMediaPlayer[display].play(display): + self.curDisplayMediaPlayer[display].set_visible(display, True) + # Start Timer for ui updates + if not self.timer.isActive(): + self.timer.start() def get_audio_extensions_list(self): audio_list = [] @@ -565,9 +558,8 @@ class MediaController(object): video_list = [] for player in self.mediaPlayers.values(): if player.isActive: - for item in player.video_extensions_list: - if not item in video_list: - video_list.append(item) + video_list.extend([item for item in player.video_extensions_list + if item not in video_list]) return video_list def finalise(self): diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 70a5c1cb5..21f8efedf 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -26,23 +26,24 @@ ############################################################################### import logging -import sys, os +import os +import sys from datetime import datetime + +from PyQt4 import QtCore, QtGui + +VLC_AVAILABLE = False try: import vlc - vlc_available = bool(vlc.get_default_instance()) + VLC_AVAILABLE = bool(vlc.get_default_instance()) except (ImportError, NameError): - vlc_available = False + pass except OSError, e: if sys.platform.startswith('win'): - if isinstance(e, WindowsError) and e.winerror == 126: - vlc_available = False - else: + if not isinstance(e, WindowsError) and e.winerror != 126: raise else: raise - -from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver from openlp.core.lib.mediaplayer import MediaPlayer from openlp.core.ui.media import MediaState @@ -128,7 +129,7 @@ class VlcPlayer(MediaPlayer): self.hasOwnWidget = True def check_available(self): - return vlc_available + return VLC_AVAILABLE def load(self, display): log.debug(u'load vid in Vlc Controller') From f01252c23b0d029827d785e1baa0040cb5fd40fb Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 28 Apr 2012 13:31:42 +0200 Subject: [PATCH 04/15] fixed missing word --- openlp/core/ui/media/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/media/__init__.py b/openlp/core/ui/media/__init__.py index ff6f7ae91..5c4428a61 100644 --- a/openlp/core/ui/media/__init__.py +++ b/openlp/core/ui/media/__init__.py @@ -72,7 +72,7 @@ def get_media_players(): the settings. ``players_list`` - Awith all active media players. + A list with all active media players. ``overridden_player`` Here an special media player is chosen for all media actions. From 1869fd7593b3f003da06b8ad7ecd478219f55f6a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 28 Apr 2012 13:37:39 +0200 Subject: [PATCH 05/15] fixed clean up mistake --- openlp/core/ui/media/mediacontroller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index bf5bcf808..b7356fcf5 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -496,7 +496,7 @@ class MediaController(object): controller = self.parent.liveController for display in self.curDisplayMediaPlayer.keys(): if display.controller != controller or \ - self.curDisplayMediaPlayer[display].state == MediaState.Playing: + self.curDisplayMediaPlayer[display].state != MediaState.Playing: continue self.curDisplayMediaPlayer[display].pause(display) self.curDisplayMediaPlayer[display].set_visible(display, False) From 42bc12f3fb1b908e4b3ee7b572db9fbc12a78bb5 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 28 Apr 2012 14:27:18 +0200 Subject: [PATCH 06/15] try to prevent traceback when vlc too old Fixes: https://launchpad.net/bugs/966086 --- openlp/core/ui/media/vlcplayer.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 21f8efedf..2f3b2a5d7 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -25,13 +25,19 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +from datetime import datetime import logging import os import sys -from datetime import datetime from PyQt4 import QtCore, QtGui +from openlp.core.lib import Receiver +from openlp.core.lib.mediaplayer import MediaPlayer +from openlp.core.ui.media import MediaState + +log = logging.getLogger(__name__) + VLC_AVAILABLE = False try: import vlc @@ -44,11 +50,19 @@ except OSError, e: raise else: raise -from openlp.core.lib import Receiver -from openlp.core.lib.mediaplayer import MediaPlayer -from openlp.core.ui.media import MediaState -log = logging.getLogger(__name__) +if VLC_AVAILABLE: + try: + # Older versions of vlc fail here. + vlcInstance = vlc.Instance() + vlcInstance.media_player_new() + except AttributeError: + VLC_AVAILABLE = False + version = u'0.0.0' + try: + version = vlc.libvlc_get_version() + finally: + log.debug(u'VlC could not be loaded: %s' % version) AUDIO_EXT = [ u'*.mp3' From 9dc7d1a7952887c76390dd7e9861df835dfd1239 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 28 Apr 2012 14:28:38 +0200 Subject: [PATCH 07/15] fixed cap --- openlp/core/ui/media/vlcplayer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 2f3b2a5d7..79b972838 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -62,7 +62,7 @@ if VLC_AVAILABLE: try: version = vlc.libvlc_get_version() finally: - log.debug(u'VlC could not be loaded: %s' % version) + log.debug(u'VLC could not be loaded: %s' % version) AUDIO_EXT = [ u'*.mp3' From 9668b22f859ce157c59324fbd55aa632a7873835 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 28 Apr 2012 15:10:54 +0200 Subject: [PATCH 08/15] shorter solution --- openlp/core/ui/media/vlcplayer.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 79b972838..2e0b250d3 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -26,6 +26,7 @@ ############################################################################### from datetime import datetime +from distutils.version import LooseVersion import logging import os import sys @@ -53,16 +54,12 @@ except OSError, e: if VLC_AVAILABLE: try: - # Older versions of vlc fail here. - vlcInstance = vlc.Instance() - vlcInstance.media_player_new() - except AttributeError: - VLC_AVAILABLE = False + version = vlc.libvlc_get_version() + except: version = u'0.0.0' - try: - version = vlc.libvlc_get_version() - finally: - log.debug(u'VLC could not be loaded: %s' % version) + if LooseVersion(version) < '1.1.0': + VLC_AVAILABLE = False + log.debug(u'VLC could not be loaded: %s' % version) AUDIO_EXT = [ u'*.mp3' From 69affcc059976c8d9910aed386b0d3e3b11b7a20 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 28 Apr 2012 15:51:05 +0200 Subject: [PATCH 09/15] removed dead code, refactor version comparison code --- openlp/.version | 2 +- openlp/core/__init__.py | 3 +- openlp/core/utils/__init__.py | 62 ++++++++++------------------------- 3 files changed, 19 insertions(+), 48 deletions(-) diff --git a/openlp/.version b/openlp/.version index 998994b7f..eeef06aee 100644 --- a/openlp/.version +++ b/openlp/.version @@ -1 +1 @@ -1.9.5-bzr1421 \ No newline at end of file +1.9.9-bzr1956 diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index b6efd5595..71c27a1d0 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -49,7 +49,7 @@ from openlp.core.ui.firsttimeform import FirstTimeForm from openlp.core.ui.exceptionform import ExceptionForm from openlp.core.ui import SplashScreen, ScreenList from openlp.core.utils import AppLocation, LanguageManager, VersionThread, \ - get_application_version, DelayStartThread + get_application_version __all__ = [u'OpenLP', u'main'] @@ -145,7 +145,6 @@ class OpenLP(QtGui.QApplication): VersionThread(self.mainWindow).start() Receiver.send_message(u'live_display_blank_check') self.mainWindow.appStartup() - DelayStartThread(self.mainWindow).start() # Skip exec_() for gui tests if not testing: return self.exec_() diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index e06c5ed32..594ce9623 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -27,14 +27,15 @@ """ The :mod:`openlp.core.utils` module provides the utility libraries for OpenLP. """ +from datetime import datetime +from distutils.version import LooseVersion import logging import os import re +from subprocess import Popen, PIPE import sys import time import urllib2 -from datetime import datetime -from subprocess import Popen, PIPE from PyQt4 import QtGui, QtCore @@ -55,7 +56,6 @@ UNO_CONNECTION_TYPE = u'pipe' #UNO_CONNECTION_TYPE = u'socket' CONTROL_CHARS = re.compile(r'[\x00-\x1F\x7F-\x9F]', re.UNICODE) INVALID_FILE_CHARS = re.compile(r'[\\/:\*\?"<>\|\+\[\]%]', re.UNICODE) -VERSION_SPLITTER = re.compile(r'([0-9]+).([0-9]+).([0-9]+)(?:-bzr([0-9]+))?') class VersionThread(QtCore.QThread): """ @@ -72,49 +72,8 @@ class VersionThread(QtCore.QThread): time.sleep(1) app_version = get_application_version() version = check_latest_version(app_version) - print app_version, version - remote_version = {} - local_version = {} - match = VERSION_SPLITTER.match(version) - if match: - remote_version[u'major'] = int(match.group(1)) - remote_version[u'minor'] = int(match.group(2)) - remote_version[u'release'] = int(match.group(3)) - if len(match.groups()) > 3 and match.group(4): - remote_version[u'revision'] = int(match.group(4)) - else: - return - match = VERSION_SPLITTER.match(app_version[u'full']) - if match: - local_version[u'major'] = int(match.group(1)) - local_version[u'minor'] = int(match.group(2)) - local_version[u'release'] = int(match.group(3)) - if len(match.groups()) > 3 and match.group(4): - local_version[u'revision'] = int(match.group(4)) - else: - return - if remote_version[u'major'] > local_version[u'major'] or \ - remote_version[u'minor'] > local_version[u'minor'] or \ - remote_version[u'release'] > local_version[u'release']: + if LooseVersion(str(version)) > str(app_version[u'full']): Receiver.send_message(u'openlp_version_check', u'%s' % version) - elif remote_version.get(u'revision') and \ - local_version.get(u'revision') and \ - remote_version[u'revision'] > local_version[u'revision']: - Receiver.send_message(u'openlp_version_check', u'%s' % version) - - -class DelayStartThread(QtCore.QThread): - """ - A special Qt thread class to build things after OpenLP has started - """ - def __init__(self, parent): - QtCore.QThread.__init__(self, parent) - - def run(self): - """ - Run the thread. - """ - Receiver.send_message(u'openlp_phonon_creation') class AppLocation(object): @@ -182,6 +141,7 @@ class AppLocation(object): check_directory_exists(path) return path + def _get_os_dir_path(dir_type): """ Return a path based on which OS and environment we are running in. @@ -221,6 +181,7 @@ def _get_os_dir_path(dir_type): u'.openlp', u'data') return os.path.join(unicode(os.getenv(u'HOME'), encoding), u'.openlp') + def _get_frozen_path(frozen_option, non_frozen_option): """ Return a path based on the system status. @@ -229,6 +190,7 @@ def _get_frozen_path(frozen_option, non_frozen_option): return frozen_option return non_frozen_option + def get_application_version(): """ Returns the application version of the running instance of OpenLP:: @@ -308,6 +270,7 @@ def get_application_version(): log.info(u'Openlp version %s' % APPLICATION_VERSION[u'version']) return APPLICATION_VERSION + def check_latest_version(current_version): """ Check the latest version of OpenLP against the version file on the OpenLP @@ -341,6 +304,7 @@ def check_latest_version(current_version): version_string = remote_version return version_string + def add_actions(target, actions): """ Adds multiple actions to a menu or toolbar in one command. @@ -358,6 +322,7 @@ def add_actions(target, actions): else: target.addAction(action) + def get_filesystem_encoding(): """ Returns the name of the encoding used to convert Unicode filenames into @@ -368,6 +333,7 @@ def get_filesystem_encoding(): encoding = sys.getdefaultencoding() return encoding + def get_images_filter(): """ Returns a filter string for a file dialog containing all the supported @@ -384,6 +350,7 @@ def get_images_filter(): visible_formats, actual_formats) return IMAGES_FILTER + def split_filename(path): """ Return a list of the parts in a given path. @@ -394,6 +361,7 @@ def split_filename(path): else: return os.path.split(path) + def clean_filename(filename): """ Removes invalid characters from the given ``filename``. @@ -405,6 +373,7 @@ def clean_filename(filename): filename = unicode(filename, u'utf-8') return INVALID_FILE_CHARS.sub(u'_', CONTROL_CHARS.sub(u'', filename)) + def delete_file(file_path_name): """ Deletes a file from the system. @@ -422,6 +391,7 @@ def delete_file(file_path_name): log.exception("Unable to delete file %s" % file_path_name) return False + def get_web_page(url, header=None, update_openlp=False): """ Attempts to download the webpage at url and returns that page or None. @@ -458,6 +428,7 @@ def get_web_page(url, header=None, update_openlp=False): log.debug(page) return page + def get_uno_command(): """ Returns the UNO command to launch an openoffice.org instance. @@ -470,6 +441,7 @@ def get_uno_command(): CONNECTION = u'"-accept=socket,host=localhost,port=2002;urp;"' return u'%s %s %s' % (COMMAND, OPTIONS, CONNECTION) + def get_uno_instance(resolver): """ Returns a running openoffice.org instance. From 76c004bb9a0d5cfd8d39876641c4f9ef790280a4 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 28 Apr 2012 18:19:02 +0200 Subject: [PATCH 10/15] fixed LooseVersion usage --- openlp/core/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 594ce9623..c276c1f8e 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -72,7 +72,7 @@ class VersionThread(QtCore.QThread): time.sleep(1) app_version = get_application_version() version = check_latest_version(app_version) - if LooseVersion(str(version)) > str(app_version[u'full']): + if LooseVersion(str(version)) > LooseVersion(str(app_version[u'full'])): Receiver.send_message(u'openlp_version_check', u'%s' % version) From f6177c62b2de8a083db21d817780f3ae46452f04 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 28 Apr 2012 18:22:37 +0200 Subject: [PATCH 11/15] fixed LooseVersion usage --- openlp/core/ui/media/vlcplayer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 2e0b250d3..6d26f3b34 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -57,7 +57,7 @@ if VLC_AVAILABLE: version = vlc.libvlc_get_version() except: version = u'0.0.0' - if LooseVersion(version) < '1.1.0': + if LooseVersion(version) < LooseVersion('1.1.0'): VLC_AVAILABLE = False log.debug(u'VLC could not be loaded: %s' % version) From c6c62bdcad6c79f90ca6c7e0558f3a2596103227 Mon Sep 17 00:00:00 2001 From: M2j Date: Sun, 29 Apr 2012 17:31:56 +0200 Subject: [PATCH 12/15] pythonifying code: - replace has_key() by key in dict - remove len() method from sequence and mapping types when mapping to bool --- openlp/core/theme/theme.py | 2 +- openlp/core/ui/mainwindow.py | 2 +- openlp/core/ui/media/mediacontroller.py | 4 +- openlp/core/ui/servicemanager.py | 6 +-- openlp/core/ui/shortcutlistform.py | 12 ++--- openlp/core/ui/slidecontroller.py | 4 +- openlp/core/ui/thememanager.py | 2 +- openlp/core/utils/__init__.py | 2 +- openlp/core/utils/actions.py | 4 +- openlp/plugins/alerts/forms/alertform.py | 2 +- openlp/plugins/bibles/bibleplugin.py | 4 +- .../plugins/bibles/forms/bibleupgradeform.py | 9 ++-- openlp/plugins/bibles/lib/__init__.py | 4 +- openlp/plugins/bibles/lib/http.py | 2 +- openlp/plugins/bibles/lib/mediaitem.py | 6 +-- openlp/plugins/custom/forms/editcustomform.py | 2 +- openlp/plugins/custom/lib/mediaitem.py | 2 +- openlp/plugins/songs/forms/editverseform.py | 6 +-- .../songs/forms/songmaintenanceform.py | 4 +- openlp/plugins/songs/lib/__init__.py | 2 +- openlp/plugins/songs/lib/cclifileimport.py | 2 +- openlp/plugins/songs/lib/easyslidesimport.py | 44 ++++++------------- openlp/plugins/songs/lib/ewimport.py | 10 ++--- openlp/plugins/songs/lib/mediaitem.py | 17 ++++--- openlp/plugins/songs/lib/olp1import.py | 5 +-- openlp/plugins/songs/lib/opensongimport.py | 24 ++++------ openlp/plugins/songs/lib/songimport.py | 15 +++---- .../plugins/songs/lib/songshowplusimport.py | 2 +- openlp/plugins/songs/lib/xml.py | 2 +- openlp/plugins/songs/songsplugin.py | 2 +- 30 files changed, 87 insertions(+), 117 deletions(-) diff --git a/openlp/core/theme/theme.py b/openlp/core/theme/theme.py index 90ca6cf6c..a77ab0c54 100644 --- a/openlp/core/theme/theme.py +++ b/openlp/core/theme/theme.py @@ -209,7 +209,7 @@ class Theme(object): val = int(element_text[1:], 16) except ValueError: # nope pass - elif DELPHI_COLORS.has_key(element_text): + elif element_text in DELPHI_COLORS: val = DELPHI_COLORS[element_text] delphi_color_change = True else: diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 0ebf66aab..e4a4e1616 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -730,7 +730,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if self.liveController.display.isVisible(): self.liveController.display.setFocus() self.activateWindow() - if len(self.arguments): + if self.arguments: args = [] for a in self.arguments: args.extend([a]) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 7ccbd9245..73283ea9b 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -127,7 +127,7 @@ class MediaController(object): invalidMediaPlayers = [mediaPlayer for mediaPlayer in savedPlayers \ if not mediaPlayer in self.mediaPlayers or \ not self.mediaPlayers[mediaPlayer].check_available()] - if len(invalidMediaPlayers) > 0: + if invalidMediaPlayers: for invalidPlayer in invalidMediaPlayers: savedPlayers.remove(invalidPlayer) set_media_players(savedPlayers, overriddenPlayer) @@ -141,7 +141,7 @@ class MediaController(object): Check if there is a running media Player and do updating stuff (e.g. update the UI) """ - if len(self.curDisplayMediaPlayer.keys()) == 0: + if not self.curDisplayMediaPlayer: self.timer.stop() else: for display in self.curDisplayMediaPlayer.keys(): diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index deb2b306f..c9dfeae50 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -483,7 +483,7 @@ class ServiceManager(QtGui.QWidget): service_item = item[u'service_item'].get_service_repr() # Get all the audio files, and ready them for embedding in the # service file. - if len(service_item[u'header'][u'background_audio']) > 0: + if service_item[u'header'][u'background_audio']: for i, filename in \ enumerate(service_item[u'header'][u'background_audio']): new_file = os.path.join(u'audio', @@ -822,7 +822,7 @@ class ServiceManager(QtGui.QWidget): """ Called by the SlideController to select the next service item. """ - if len(self.serviceManagerList.selectedItems()) == 0: + if not self.serviceManagerList.selectedItems(): return selected = self.serviceManagerList.selectedItems()[0] lookFor = 0 @@ -840,7 +840,7 @@ class ServiceManager(QtGui.QWidget): """ Called by the SlideController to select the previous service item. """ - if len(self.serviceManagerList.selectedItems()) == 0: + if not self.serviceManagerList.selectedItems(): return selected = self.serviceManagerList.selectedItems()[0] prevItem = None diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 211946793..457525dc0 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -151,7 +151,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): if action is None: continue shortcuts = self._actionShortcuts(action) - if len(shortcuts) == 0: + if not shortcuts: item.setText(1, u'') item.setText(2, u'') elif len(shortcuts) == 1: @@ -195,7 +195,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): return shortcuts = self._actionShortcuts(action) new_shortcuts = [] - if len(shortcuts) != 0: + if shortcuts: new_shortcuts.append(shortcuts[0]) new_shortcuts.append( QtGui.QKeySequence(self.alternatePushButton.text())) @@ -241,7 +241,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.primaryPushButton.setChecked(False) self.alternatePushButton.setChecked(False) else: - if len(action.defaultShortcuts) != 0: + if action.defaultShortcuts: primary_label_text = action.defaultShortcuts[0].toString() if len(action.defaultShortcuts) == 2: alternate_label_text = action.defaultShortcuts[1].toString() @@ -313,7 +313,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.refreshShortcutList() primary_button_text = u'' alternate_button_text = u'' - if len(temp_shortcuts) != 0: + if temp_shortcuts: primary_button_text = temp_shortcuts[0].toString() if len(temp_shortcuts) == 2: alternate_button_text = temp_shortcuts[1].toString() @@ -363,7 +363,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): return shortcuts = self._actionShortcuts(action) new_shortcuts = [] - if len(action.defaultShortcuts) != 0: + if action.defaultShortcuts: new_shortcuts.append(action.defaultShortcuts[0]) # We have to check if the primary default shortcut is available. But # we only have to check, if the action has a default primary @@ -391,7 +391,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): return shortcuts = self._actionShortcuts(action) new_shortcuts = [] - if len(shortcuts) != 0: + if shortcuts: new_shortcuts.append(shortcuts[0]) if len(action.defaultShortcuts) == 2: new_shortcuts.append(action.defaultShortcuts[1]) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index a1b3a84b2..9de6555f2 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -555,7 +555,7 @@ class SlideController(Controller): Process the service item request queue. The key presses can arrive faster than the processing so implement a FIFO queue. """ - if len(self.keypress_queue): + if self.keypress_queue: while len(self.keypress_queue) and not self.keypress_loop: self.keypress_loop = True keypressCommand = self.keypress_queue.popleft() @@ -694,7 +694,7 @@ class SlideController(Controller): if item.is_text(): if QtCore.QSettings().value( self.parent().songsSettingsSection + u'/display songbar', - QtCore.QVariant(True)).toBool() and len(self.slideList) > 0: + QtCore.QVariant(True)).toBool() and self.slideList: self.songMenu.show() if item.is_capable(ItemCapabilities.CanLoop) and \ len(item.get_frames()) > 1: diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 421346ba9..665c435b9 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -444,7 +444,7 @@ class ThemeManager(QtGui.QWidget): self.firstTime() files = SettingsManager.get_files(self.settingsSection, u'.png') # No themes have been found so create one - if len(files) == 0: + if not files: theme = ThemeXML() theme.theme_name = UiStrings().Default self._writeTheme(theme, None, None) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 1fc75b6d8..f71ec25cd 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -267,7 +267,7 @@ def get_application_version(): if code != 0: raise Exception(u'Error running bzr tags') lines = output.splitlines() - if len(lines) == 0: + if not lines: tag = u'0.0.0' revision = u'0' else: diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 1a7d99fa5..271a7c884 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -90,7 +90,7 @@ class CategoryActionList(object): def append(self, name): weight = 0 - if len(self.actions) > 0: + if self.actions: weight = self.actions[-1][0] + 1 self.add(name, weight) @@ -156,7 +156,7 @@ class CategoryList(object): def append(self, name, actions=None): weight = 0 - if len(self.categories) > 0: + if self.categories: weight = self.categories[-1].weight + 1 if actions: self.add(name, weight, actions) diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index d2d4813a1..4f7633062 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -101,7 +101,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): self.alertTextEdit.setText(u'') def onNewClick(self): - if len(self.alertTextEdit.text()) == 0: + if not self.alertTextEdit.text(): QtGui.QMessageBox.information(self, translate('AlertsPlugin.AlertForm', 'New Alert'), translate('AlertsPlugin.AlertForm', 'You haven\'t specified ' diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 06d8b1c98..0dddab214 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -62,7 +62,7 @@ class BiblePlugin(Plugin): # unicode(UiStrings().Export)) # Set to invisible until we can export bibles self.exportBibleItem.setVisible(False) - if len(self.manager.old_bible_databases): + if self.manager.old_bible_databases: self.toolsUpgradeItem.setVisible(True) def finalise(self): @@ -83,7 +83,7 @@ class BiblePlugin(Plugin): """ Perform tasks on application startup """ - if len(self.manager.old_bible_databases): + if self.manager.old_bible_databases: if QtGui.QMessageBox.information(self.formParent, translate('OpenLP', 'Information'), translate('OpenLP', 'Bible format has changed.\nYou have to upgrade your ' diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 0ef418de8..88bbd8c63 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -426,8 +426,7 @@ class BibleUpgradeForm(OpenLPWizard): if meta[u'key'] == u'download_source': web_bible = True self.includeWebBible = True - if meta.has_key(u'proxy_server'): - proxy_server = meta[u'proxy_server'] + proxy_server = meta.get(u'proxy_server') if web_bible: if meta_data[u'download_source'].lower() == u'crosswalk': handler = CWExtract(proxy_server) @@ -572,7 +571,7 @@ class BibleUpgradeForm(OpenLPWizard): int(verse[u'verse']), unicode(verse[u'text'])) Receiver.send_message(u'openlp_process_events') self.newbibles[number].session.commit() - if self.success.has_key(number) and not self.success[number]: + if not self.success.get(number, True): self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\nFailed')) % @@ -586,7 +585,7 @@ class BibleUpgradeForm(OpenLPWizard): 'Upgrading Bible %s of %s: "%s"\n' 'Complete')) % (number + 1, max_bibles, name)) - if self.newbibles.has_key(number): + if number in self.newbibles: self.newbibles[number].session.close() # Close the last bible's connection if possible. if old_bible is not None: @@ -599,7 +598,7 @@ class BibleUpgradeForm(OpenLPWizard): successful_import = 0 failed_import = 0 for number, filename in enumerate(self.files): - if self.success.has_key(number) and self.success[number]: + if self.success.get(number): successful_import += 1 elif self.checkBox[number].checkState() == QtCore.Qt.Checked: failed_import += 1 diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index 4f8582bdf..6cd8b8d8e 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -236,7 +236,7 @@ def get_reference_separator(separator_type): ``separator_type`` The role and format of the separator. """ - if len(REFERENCE_SEPARATORS) == 0: + if not REFERENCE_SEPARATORS: update_reference_separators() return REFERENCE_SEPARATORS[separator_type] @@ -247,7 +247,7 @@ def get_reference_match(match_type): ``match_type`` The type of match is ``range_separator``, ``range`` or ``full``. """ - if len(REFERENCE_MATCHES) == 0: + if not REFERENCE_MATCHES: update_reference_separators() return REFERENCE_MATCHES[match_type] diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 302bdf999..fb79b26e1 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -106,7 +106,7 @@ class BGExtract(object): verse_list = {} # Cater for inconsistent mark up in the first verse of a chapter. first_verse = verses.find(u'versenum') - if first_verse and len(first_verse.contents): + if first_verse and first_verse.contents: verse_list[1] = unicode(first_verse.contents[0]) for verse in verses(u'sup', u'versenum'): raw_verse_num = verse.next diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index e3d173fad..bc456ee69 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -392,7 +392,7 @@ class BibleMediaItem(MediaManagerItem): if bible in bibles: find_and_set_in_combo_box(self.advancedVersionComboBox, bible) self.initialiseAdvancedBible(unicode(bible)) - elif len(bibles): + elif bibles: self.initialiseAdvancedBible(bibles[0]) bible = QtCore.QSettings().value( self.settingsSection + u'/quick bible', QtCore.QVariant( @@ -878,7 +878,7 @@ class BibleMediaItem(MediaManagerItem): items = item else: items = self.listView.selectedItems() - if len(items) == 0: + if not items: return False bible_text = u'' old_item = None @@ -949,7 +949,7 @@ class BibleMediaItem(MediaManagerItem): # Service Item: Title service_item.title = create_separated_list(raw_title) # Service Item: Theme - if len(self.settings.bible_theme) == 0: + if not self.settings.bible_theme: service_item.theme = None else: service_item.theme = self.settings.bible_theme diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 7c2da3bb0..a113a9e1b 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -254,7 +254,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): Checks whether a custom is valid or not. """ # We must have a title. - if len(self.titleEdit.displayText()) == 0: + if not self.titleEdit.displayText(): self.titleEdit.setFocus() critical_error_message_box( message=translate('CustomPlugin.EditCustomForm', diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 541403cda..af2f261ca 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -258,7 +258,7 @@ class CustomMediaItem(MediaManagerItem): search_length = 2 if len(text) > search_length: self.onSearchTextButtonClicked() - elif len(text) == 0: + elif not text: self.onClearTextButtonClick() def onClearTextButtonClick(self): diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index 1e7bf4375..21285f39d 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -191,13 +191,13 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): else: log.debug(unicode(self.getVerse()[0]).split(u'\n')) value = unicode(self.getVerse()[0]).split(u'\n')[1] - if len(value) == 0: + if not value: lines = unicode(self.getVerse()[0]).split(u'\n') index = 2 - while index < len(lines) and len(value) == 0: + while index < len(lines) and not value: value = lines[index] index += 1 - if len(value) == 0: + if not value: critical_error_message_box( message=translate('SongsPlugin.EditSongForm', 'You need to type some text in to the verse.')) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 697bcb4fe..7ba49a102 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -108,7 +108,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): item_id = self._getCurrentItemId(list_widget) if item_id != -1: item = self.manager.get_object(item_class, item_id) - if item and len(item.songs) == 0: + if item and not item.songs: if critical_error_message_box(dlg_title, del_text, self, True) == QtGui.QMessageBox.Yes: self.manager.delete_object(item_class, item.id) @@ -191,7 +191,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): ``edit`` If we edit an item, this should be *True*. """ - if len(objects) > 0: + if objects: # If we edit an existing object, we need to make sure that we do # not return False when nothing has changed. if edit: diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 91e21bb19..44cf8e113 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -316,7 +316,7 @@ def clean_song(manager, song): verse_type, verse[0][u'label'], verse[1], - verse[0][u'lang'] if verse[0].has_key(u'lang') else None + verse[0].get(u'lang') ) compare_order.append((u'%s%s' % (verse_type, verse[0][u'label']) ).upper()) diff --git a/openlp/plugins/songs/lib/cclifileimport.py b/openlp/plugins/songs/lib/cclifileimport.py index 6b99f9a16..c2df6ab4e 100644 --- a/openlp/plugins/songs/lib/cclifileimport.py +++ b/openlp/plugins/songs/lib/cclifileimport.py @@ -211,7 +211,7 @@ class CCLIFileImport(SongImport): elif verse_lines[0].startswith(u'('): verse_type = VerseType.Tags[VerseType.Other] verse_text = verse_lines[1] - if len(verse_text) > 0: + if verse_text: self.addVerse(verse_text, verse_type) check_first_verse_line = False # Handle multiple authors diff --git a/openlp/plugins/songs/lib/easyslidesimport.py b/openlp/plugins/songs/lib/easyslidesimport.py index 206c127f5..eb21e6fc2 100644 --- a/openlp/plugins/songs/lib/easyslidesimport.py +++ b/openlp/plugins/songs/lib/easyslidesimport.py @@ -162,15 +162,12 @@ class EasySlidesImport(SongImport): separatorlines = 0 for line in lines: line = line.strip() - if len(line) == 0: + if not line: continue elif line[1:7] == u'region': # this is region separator, probably [region 2] region = self._extractRegion(line) - if regionlines.has_key(region): - regionlines[region] = regionlines[region] + 1 - else: - regionlines[region] = 1 + regionlines[region] = 1 + regionlines.get(region, 0) elif line[0] == u'[': separatorlines = separatorlines + 1 # if the song has separators @@ -206,7 +203,7 @@ class EasySlidesImport(SongImport): for line in lines: line = line.strip() - if len(line) == 0: + if not line: if separators: # separators are used, so empty line means slide break # inside verse @@ -215,15 +212,11 @@ class EasySlidesImport(SongImport): else: # separators are not used, so empty line starts a new verse vt = u'V' - if verses[reg].has_key(vt): - vn = len(verses[reg][vt].keys())+1 - else: - vn = u'1' + vn = len(verses[reg].get(vt, {})) + 1 inst = 1 elif line[0:7] == u'[region': reg = self._extractRegion(line) - if not verses.has_key(reg): - verses[reg] = {} + verses.setdefault(reg, {}) if not regionsInVerses: vt = u'V' vn = u'1' @@ -238,12 +231,7 @@ class EasySlidesImport(SongImport): if match: marker = match.group(1).strip() vn = match.group(2) - if len(marker) == 0: - vt = u'V' - elif MarkTypes.has_key(marker): - vt = MarkTypes[marker] - else: - vt = u'O' + vt = MarkTypes.get(marker, u'O') if marker else u'V' if regionsInVerses: region = defaultregion inst = 1 @@ -252,14 +240,10 @@ class EasySlidesImport(SongImport): else: if not [reg, vt, vn, inst] in our_verse_order: our_verse_order.append([reg, vt, vn, inst]) - if not verses[reg].has_key(vt): - verses[reg][vt] = {} - if not verses[reg][vt].has_key(vn): - verses[reg][vt][vn] = {} - if not verses[reg][vt][vn].has_key(inst): - verses[reg][vt][vn][inst] = [] - words = self.tidyText(line) - verses[reg][vt][vn][inst].append(words) + verses[reg].setdefault(vt, {}) + verses[reg][vt].setdefault(vn, {}) + verses[reg][vt][vn].setdefault(inst, []) + verses[reg][vt][vn][inst].append(self.tidyText(line)) # done parsing versetags = [] @@ -286,11 +270,11 @@ class EasySlidesImport(SongImport): try: order = unicode(song.Sequence).strip().split(u',') for tag in order: - if len(tag) == 0: + if not tag: continue elif tag[0].isdigit(): tag = u'V' + tag - elif SeqTypes.has_key(tag.lower()): + elif tag.lower() in SeqTypes: tag = SeqTypes[tag.lower()] else: continue @@ -307,9 +291,7 @@ class EasySlidesImport(SongImport): def _listHas(self, lst, subitems): for subitem in subitems: - if isinstance(lst, dict) and lst.has_key(subitem): - lst = lst[subitem] - elif isinstance(lst, list) and subitem in lst: + if subitem in lst: lst = lst[subitem] else: return False diff --git a/openlp/plugins/songs/lib/ewimport.py b/openlp/plugins/songs/lib/ewimport.py index f17900fd5..d58734610 100644 --- a/openlp/plugins/songs/lib/ewimport.py +++ b/openlp/plugins/songs/lib/ewimport.py @@ -62,15 +62,15 @@ def strip_rtf(blob, encoding): if control: # for delimiters, set control to False if c == '{': - if len(control_word) > 0: + if control_word: depth += 1 control = False elif c == '}': - if len(control_word) > 0: + if control_word: depth -= 1 control = False elif c == '\\': - new_control = (len(control_word) > 0) + new_control = bool(control_word) control = False elif c.isspace(): control = False @@ -79,7 +79,7 @@ def strip_rtf(blob, encoding): if len(control_word) == 3 and control_word[0] == '\'': control = False if not control: - if len(control_word) == 0: + if not control_word: if c == '{' or c == '}' or c == '\\': clear_text.append(c) else: @@ -360,7 +360,7 @@ class EasyWorshipSongImport(SongImport): field_desc = self.fieldDescs[field_desc_index] # Return None in case of 'blank' entries if isinstance(field, str): - if len(field.rstrip('\0')) == 0: + if not field.rstrip('\0'): return None elif field == 0: return None diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 2836e98ad..51158a954 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -295,9 +295,8 @@ class SongMediaItem(MediaManagerItem): log.debug(u'display results Book') self.listView.clear() for book in searchresults: - songs = sorted(book.songs, key=lambda song: int( - re.sub(r'[^0-9]', u' ', song.song_number).partition(' ')[0]) - if len(re.sub(r'[^\w]', ' ', song.song_number)) else 0) + songs = sorted(book.songs, key=lambda song: + int(re.match(r'[0-9]+', u'0' + song.song_number).group())) for song in songs: # Do not display temporary songs if song.temporary: @@ -331,7 +330,7 @@ class SongMediaItem(MediaManagerItem): search_length = 3 if len(text) > search_length: self.onSearchTextButtonClicked() - elif len(text) == 0: + elif not text: self.onClearTextButtonClick() def onImportClick(self): @@ -491,7 +490,7 @@ class SongMediaItem(MediaManagerItem): else: # Loop through the verse list and expand the song accordingly. for order in song.verse_order.lower().split(): - if len(order) == 0: + if not order: break for verse in verseList: if verse[0][u'type'][0].lower() == order[0] and \ @@ -530,7 +529,7 @@ class SongMediaItem(MediaManagerItem): u'authors': u', '.join(author_list)} service_item.xml_version = self.openLyrics.song_to_xml(song) # Add the audio file to the service item. - if len(song.media_files) > 0: + if song.media_files: service_item.add_capability(ItemCapabilities.HasBackgroundAudio) service_item.background_audio = \ [m.file_name for m in song.media_files] @@ -575,12 +574,12 @@ class SongMediaItem(MediaManagerItem): editId = song.id break # If there's any backing tracks, copy them over. - if len(item.background_audio) > 0: + if item.background_audio: self._updateBackgroundAudio(song, item) if add_song and self.addSongFromService: song = self.openLyrics.xml_to_song(item.xml_version) # If there's any backing tracks, copy them over. - if len(item.background_audio) > 0: + if item.background_audio: self._updateBackgroundAudio(song, item) editId = song.id self.onSearchTextButtonClicked() @@ -588,7 +587,7 @@ class SongMediaItem(MediaManagerItem): # Make sure we temporary import formatting tags. song = self.openLyrics.xml_to_song(item.xml_version, True) # If there's any backing tracks, copy them over. - if len(item.background_audio) > 0: + if item.background_audio: self._updateBackgroundAudio(song, item) editId = song.id temporary = True diff --git a/openlp/plugins/songs/lib/olp1import.py b/openlp/plugins/songs/lib/olp1import.py index 05095aa31..2d744bd2a 100644 --- a/openlp/plugins/songs/lib/olp1import.py +++ b/openlp/plugins/songs/lib/olp1import.py @@ -122,8 +122,7 @@ class OpenLP1SongImport(SongImport): cursor.execute( u'SELECT settingsid FROM songs WHERE songid = %s' % song_id) theme_id = cursor.fetchone()[0] - if themes.has_key(theme_id): - self.themeName = themes[theme_id] + self.themeName = themes.get(theme_id, u'') verses = lyrics.split(u'\n\n') for verse in verses: if verse.strip(): @@ -191,7 +190,7 @@ class OpenLP1SongImport(SongImport): # Detect charset by songs. cursor.execute(u'SELECT name FROM sqlite_master ' u'WHERE type = \'table\' AND name = \'tracks\'') - if len(cursor.fetchall()) > 0: + if cursor.fetchall(): cursor.execute(u'SELECT fulltrackname FROM tracks') tracks = cursor.fetchall() for track in tracks: diff --git a/openlp/plugins/songs/lib/opensongimport.py b/openlp/plugins/songs/lib/opensongimport.py index ad45ef22e..f78ba474b 100644 --- a/openlp/plugins/songs/lib/opensongimport.py +++ b/openlp/plugins/songs/lib/opensongimport.py @@ -174,7 +174,7 @@ class OpenSongImport(SongImport): if semicolon >= 0: this_line = this_line[:semicolon] this_line = this_line.strip() - if not len(this_line): + if not this_line: continue # skip guitar chords and page and column breaks if this_line.startswith(u'.') or this_line.startswith(u'---') \ @@ -197,15 +197,12 @@ class OpenSongImport(SongImport): # the verse tag verse_tag = content verse_num = u'1' - if len(verse_tag) == 0: - verse_index = 0 - else: - verse_index = VerseType.from_loose_input(verse_tag) + verse_index = VerseType.from_loose_input(verse_tag) \ + if verse_tag else 0 verse_tag = VerseType.Tags[verse_index] inst = 1 if [verse_tag, verse_num, inst] in our_verse_order \ - and verses.has_key(verse_tag) \ - and verses[verse_tag].has_key(verse_num): + and verse_num in verses.get(verse_tag, {}): inst = len(verses[verse_tag][verse_num]) + 1 continue # number at start of line.. it's verse number @@ -213,11 +210,9 @@ class OpenSongImport(SongImport): verse_num = this_line[0] this_line = this_line[1:].strip() our_verse_order.append([verse_tag, verse_num, inst]) - if not verses.has_key(verse_tag): - verses[verse_tag] = {} - if not verses[verse_tag].has_key(verse_num): - verses[verse_tag][verse_num] = {} - if not verses[verse_tag][verse_num].has_key(inst): + verses.setdefault(verse_tag, {}) + verses[verse_tag].setdefault(verse_num, {}) + if inst not in verses[verse_tag][verse_num]: verses[verse_tag][verse_num][inst] = [] our_verse_order.append([verse_tag, verse_num, inst]) # Tidy text and remove the ____s from extended words @@ -252,15 +247,14 @@ class OpenSongImport(SongImport): if match is not None: verse_tag = match.group(1) verse_num = match.group(2) - if not len(verse_tag): + if not verse_tag: verse_tag = VerseType.Tags[VerseType.Verse] else: # Assume it's no.1 if there are no digits verse_tag = verse_def verse_num = u'1' verse_def = u'%s%s' % (verse_tag, verse_num) - if verses.has_key(verse_tag) and \ - verses[verse_tag].has_key(verse_num): + if verse_num in verses.get(verse_tag, {}): self.verseOrderList.append(verse_def) else: log.info(u'Got order %s but not in verse tags, dropping' diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index 6fd9dd403..74767d793 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -61,9 +61,9 @@ class SongImport(QtCore.QObject): """ self.manager = manager QtCore.QObject.__init__(self) - if kwargs.has_key(u'filename'): + if u'filename' in kwargs: self.importSource = kwargs[u'filename'] - elif kwargs.has_key(u'filenames'): + elif u'filenames' in kwargs: self.importSource = kwargs[u'filenames'] else: raise KeyError(u'Keyword arguments "filename[s]" not supplied.') @@ -273,7 +273,7 @@ class SongImport(QtCore.QObject): Author not checked here, if no author then "Author unknown" is automatically added """ - if not self.title or not len(self.verses): + if not self.title or not self.verses: return False else: return True @@ -314,13 +314,10 @@ class SongImport(QtCore.QObject): verse_def = new_verse_def sxml.add_verse_to_lyrics(verse_tag, verse_def[1:], verse_text, lang) song.lyrics = unicode(sxml.extract_xml(), u'utf-8') - if not len(self.verseOrderList) and \ - self.verseOrderListGeneratedUseful: + if not self.verseOrderList and self.verseOrderListGeneratedUseful: self.verseOrderList = self.verseOrderListGenerated - for i, current_verse_def in enumerate(self.verseOrderList): - if verses_changed_to_other.has_key(current_verse_def): - self.verseOrderList[i] = \ - verses_changed_to_other[current_verse_def] + self.verseOrderList = map(lambda v: verses_changed_to_other.get(v, v), + self.verseOrderList) song.verse_order = u' '.join(self.verseOrderList) song.copyright = self.copyright song.comments = self.comments diff --git a/openlp/plugins/songs/lib/songshowplusimport.py b/openlp/plugins/songs/lib/songshowplusimport.py index 8d2af5514..f86e061ca 100644 --- a/openlp/plugins/songs/lib/songshowplusimport.py +++ b/openlp/plugins/songs/lib/songshowplusimport.py @@ -204,7 +204,7 @@ class SongShowPlusImport(SongImport): elif verse_type == "pre-chorus": verse_tag = VerseType.Tags[VerseType.PreChorus] else: - if not self.otherList.has_key(verse_name): + if verse_name not in self.otherList: if ignore_unique: return None self.otherCount = self.otherCount + 1 diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 816742d11..fdcb1dd60 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -611,7 +611,7 @@ class OpenLyrics(object): text += u'{%s}' % element.get(u'name') # Some formattings may have only start tag. # Handle this case if element has no children and contains no text. - if len(element) == 0 and not element.text: + if not element and not element.text: use_endtag = False # Append text from element. if element.text: diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index f55ac7a5f..4d59186e5 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -239,7 +239,7 @@ class SongsPlugin(Plugin): for sfile in os.listdir(db_dir): if sfile.startswith(u'songs_') and sfile.endswith(u'.sqlite'): song_dbs.append(os.path.join(db_dir, sfile)) - if len(song_dbs) == 0: + if not song_dbs: return progress = QtGui.QProgressDialog(self.formParent) progress.setWindowModality(QtCore.Qt.WindowModal) From 41402ab0789d744dc726e9e45d88b8892c171765 Mon Sep 17 00:00:00 2001 From: M2j Date: Sun, 29 Apr 2012 18:01:15 +0200 Subject: [PATCH 13/15] add a space character --- openlp/plugins/songs/lib/easyslidesimport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/easyslidesimport.py b/openlp/plugins/songs/lib/easyslidesimport.py index eb21e6fc2..30d12964a 100644 --- a/openlp/plugins/songs/lib/easyslidesimport.py +++ b/openlp/plugins/songs/lib/easyslidesimport.py @@ -236,7 +236,7 @@ class EasySlidesImport(SongImport): region = defaultregion inst = 1 if self._listHas(verses, [reg, vt, vn, inst]): - inst = len(verses[reg][vt][vn])+1 + inst = len(verses[reg][vt][vn]) + 1 else: if not [reg, vt, vn, inst] in our_verse_order: our_verse_order.append([reg, vt, vn, inst]) From bd4cded398df67b3de98e821ed90d8c9585acaa2 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 1 May 2012 12:38:19 +0200 Subject: [PATCH 14/15] updated vlc.py --- openlp/core/ui/media/vlc.py | 61 ++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/openlp/core/ui/media/vlc.py b/openlp/core/ui/media/vlc.py index 6ad30a3e4..1f6aa0e6a 100644 --- a/openlp/core/ui/media/vlc.py +++ b/openlp/core/ui/media/vlc.py @@ -2,25 +2,26 @@ # Python ctypes bindings for VLC # -# Copyright (C) 2009-2010 the VideoLAN team +# Copyright (C) 2009-2012 the VideoLAN team # $Id: $ # # Authors: Olivier Aubert # Jean Brouwers +# Geoff Salmon # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation; either version 2.1 of the +# License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA """This module provides bindings for the LibVLC public API, see U{http://wiki.videolan.org/LibVLC}. @@ -47,7 +48,7 @@ import sys from inspect import getargspec __version__ = "N/A" -build_date = "Tue Jan 17 12:20:48 2012" +build_date = "Fri Apr 27 16:47:21 2012" # Internal guard to prevent internal classes to be directly # instanciated. @@ -126,7 +127,7 @@ class VLCException(Exception): try: _Ints = (int, long) except NameError: # no long in Python 3+ - _Ints = int + _Ints = int _Seqs = (list, tuple) # Default instance. It is used to instanciate classes directly in the @@ -904,6 +905,11 @@ class Instance(_Ctype): def media_new(self, mrl, *options): """Create a new Media instance. + If mrl contains a colon (:), it will be treated as a + URL. Else, it will be considered as a local path. If you need + more control, directly use media_new_location/media_new_path + methods. + Options can be specified as supplementary string parameters, e.g. C{m = i.media_new('foo.avi', 'sub-filter=marq{marquee=Hello}', 'vout-filter=invert')} @@ -914,7 +920,12 @@ class Instance(_Ctype): @param options: optional media option=value strings """ - m = libvlc_media_new_location(self, mrl) + if ':' in mrl: + # Assume it is a URL + m = libvlc_media_new_location(self, mrl) + else: + # Else it should be a local path. + m = libvlc_media_new_path(self, mrl) for o in options: libvlc_media_add_option(m, o) m._instance = self @@ -1511,7 +1522,7 @@ class Media(_Ctype): def save_meta(self): '''Save the meta previously set. - @return: true if the write operation was successfull. + @return: true if the write operation was successful. ''' return libvlc_media_save_meta(self) @@ -2230,7 +2241,7 @@ class MediaPlayer(_Ctype): @param format: a four-characters string identifying the sample format (e.g. "S16N" or "FL32"). @param rate: sample rate (expressed in Hz). @param channels: channels count. - @version: LibVLC 1.2.0 or later. + @version: LibVLC 2.0.0 or later. ''' return libvlc_audio_set_format(self, format, rate, channels) @@ -2378,7 +2389,7 @@ class MediaPlayer(_Ctype): def navigate(self, navigate): '''Navigate through DVD Menu. @param navigate: the Navigation mode. - @version: libVLC 1.2.0 or later. + @version: libVLC 2.0.0 or later. ''' return libvlc_media_player_navigate(self, navigate) @@ -2489,7 +2500,7 @@ class MediaPlayer(_Ctype): '''Get the current subtitle delay. Positive values means subtitles are being displayed later, negative values earlier. @return: time (in microseconds) the display of subtitles is being delayed. - @version: LibVLC 1.2.0 or later. + @version: LibVLC 2.0.0 or later. ''' return libvlc_video_get_spu_delay(self) @@ -2500,7 +2511,7 @@ class MediaPlayer(_Ctype): The subtitle delay will be reset to zero each time the media changes. @param i_delay: time (in microseconds) the display of subtitles should be delayed. @return: 0 on success, -1 on error. - @version: LibVLC 1.2.0 or later. + @version: LibVLC 2.0.0 or later. ''' return libvlc_video_set_spu_delay(self, i_delay) @@ -3247,7 +3258,7 @@ def libvlc_media_set_meta(p_md, e_meta, psz_value): def libvlc_media_save_meta(p_md): '''Save the meta previously set. @param p_md: the media desriptor. - @return: true if the write operation was successfull. + @return: true if the write operation was successful. ''' f = _Cfunctions.get('libvlc_media_save_meta', None) or \ _Cfunction('libvlc_media_save_meta', ((1,),), None, @@ -4084,7 +4095,7 @@ def libvlc_audio_set_format(mp, format, rate, channels): @param format: a four-characters string identifying the sample format (e.g. "S16N" or "FL32"). @param rate: sample rate (expressed in Hz). @param channels: channels count. - @version: LibVLC 1.2.0 or later. + @version: LibVLC 2.0.0 or later. ''' f = _Cfunctions.get('libvlc_audio_set_format', None) or \ _Cfunction('libvlc_audio_set_format', ((1,), (1,), (1,), (1,),), None, @@ -4328,7 +4339,7 @@ def libvlc_media_player_navigate(p_mi, navigate): '''Navigate through DVD Menu. @param p_mi: the Media Player. @param navigate: the Navigation mode. - @version: libVLC 1.2.0 or later. + @version: libVLC 2.0.0 or later. ''' f = _Cfunctions.get('libvlc_media_player_navigate', None) or \ _Cfunction('libvlc_media_player_navigate', ((1,), (1,),), None, @@ -4554,7 +4565,7 @@ def libvlc_video_get_spu_delay(p_mi): displayed later, negative values earlier. @param p_mi: media player. @return: time (in microseconds) the display of subtitles is being delayed. - @version: LibVLC 1.2.0 or later. + @version: LibVLC 2.0.0 or later. ''' f = _Cfunctions.get('libvlc_video_get_spu_delay', None) or \ _Cfunction('libvlc_video_get_spu_delay', ((1,),), None, @@ -4569,7 +4580,7 @@ def libvlc_video_set_spu_delay(p_mi, i_delay): @param p_mi: media player. @param i_delay: time (in microseconds) the display of subtitles should be delayed. @return: 0 on success, -1 on error. - @version: LibVLC 1.2.0 or later. + @version: LibVLC 2.0.0 or later. ''' f = _Cfunctions.get('libvlc_video_set_spu_delay', None) or \ _Cfunction('libvlc_video_set_spu_delay', ((1,), (1,),), None, From eafd3a20ae3e811d047604448bdd9c947dd30a34 Mon Sep 17 00:00:00 2001 From: M2j Date: Tue, 1 May 2012 13:03:31 +0200 Subject: [PATCH 15/15] revert openlp/core/ui/media/mediacontroller.py to prevent merge conflict --- openlp/core/ui/media/mediacontroller.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 73283ea9b..7ccbd9245 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -127,7 +127,7 @@ class MediaController(object): invalidMediaPlayers = [mediaPlayer for mediaPlayer in savedPlayers \ if not mediaPlayer in self.mediaPlayers or \ not self.mediaPlayers[mediaPlayer].check_available()] - if invalidMediaPlayers: + if len(invalidMediaPlayers) > 0: for invalidPlayer in invalidMediaPlayers: savedPlayers.remove(invalidPlayer) set_media_players(savedPlayers, overriddenPlayer) @@ -141,7 +141,7 @@ class MediaController(object): Check if there is a running media Player and do updating stuff (e.g. update the UI) """ - if not self.curDisplayMediaPlayer: + if len(self.curDisplayMediaPlayer.keys()) == 0: self.timer.stop() else: for display in self.curDisplayMediaPlayer.keys():