From 51915d0e973e7fbf8d3669421f1f36e71703cc74 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 3 Nov 2009 15:13:52 +0000 Subject: [PATCH] Truth testing cleanup --- openlp/core/lib/renderer.py | 2 +- openlp/core/lib/rendermanager.py | 4 ++-- openlp/core/ui/amendthemeform.py | 8 ++++---- openlp/core/ui/mainwindow.py | 4 ++-- openlp/core/ui/pluginform.py | 2 +- openlp/core/ui/thememanager.py | 6 +++--- openlp/plugins/bibles/lib/bibleCSVimpl.py | 10 +++++----- openlp/plugins/bibles/lib/bibleOSISimpl.py | 2 +- openlp/plugins/images/lib/mediaitem.py | 23 +++++++++++----------- 9 files changed, 31 insertions(+), 30 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index bc5c09554..c3274ec32 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -128,7 +128,7 @@ class Renderer(object): ``preview`` Defaults to *False*. Whether or not to generate a preview. """ - if preview == True: + if preview: self.bg_frame = None log.debug(u'set frame dest (frame) w %d h %d', frame_width, frame_height) diff --git a/openlp/core/lib/rendermanager.py b/openlp/core/lib/rendermanager.py index 50abcfd07..e08ecff2a 100644 --- a/openlp/core/lib/rendermanager.py +++ b/openlp/core/lib/rendermanager.py @@ -164,14 +164,14 @@ class RenderManager(object): log.debug(u'build_text_rectangle') main_rect = None footer_rect = None - if theme.font_main_override == False: + if not theme.font_main_override: main_rect = QtCore.QRect(10, 0, self.width - 1, self.footer_start - 20) else: main_rect = QtCore.QRect(int(theme.font_main_x), int(theme.font_main_y), int(theme.font_main_width)-1, int(theme.font_main_height) - 1) - if theme.font_footer_override == False: + if not theme.font_footer_override: footer_rect = QtCore.QRect(10,self.footer_start, self.width - 1, self.height-self.footer_start) else: diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index 0652ccd62..cf1e6f9e6 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -545,12 +545,12 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.FontFooterColorPushButton.setStyleSheet( u'background-color: %s' % unicode(theme.font_footer_color)) - if self.theme.font_main_override == False: + if not self.theme.font_main_override: self.FontMainDefaultCheckBox.setChecked(True) else: self.FontMainDefaultCheckBox.setChecked(False) - if self.theme.font_footer_override == False: + if not self.theme.font_footer_override: self.FontFooterDefaultCheckBox.setChecked(True) else: self.FontFooterDefaultCheckBox.setChecked(False) @@ -635,7 +635,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.GradientLabel.setVisible(False) self.GradientComboBox.setVisible(False) - if theme.font_main_override == False: + if not theme.font_main_override: self.FontMainXSpinBox.setEnabled(False) self.FontMainYSpinBox.setEnabled(False) self.FontMainWidthSpinBox.setEnabled(False) @@ -646,7 +646,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.FontMainWidthSpinBox.setEnabled(True) self.FontMainHeightSpinBox.setEnabled(True) - if theme.font_footer_override == False: + if not theme.font_footer_override: self.FontFooterXSpinBox.setEnabled(False) self.FontFooterYSpinBox.setEnabled(False) self.FontFooterWidthSpinBox.setEnabled(False) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index a2c6c6070..abb5062da 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -606,7 +606,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ Hook to close the main window and display windows on exit """ - if self.serviceNotSaved == True: + if self.serviceNotSaved: ret = QtGui.QMessageBox.question(None, self.trUtf8(u'Save Changes to Service?'), self.trUtf8(u'Your service has changed, do you want to save those changes?'), @@ -655,7 +655,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): service_name = u'(unsaved service)' else: service_name = serviceName - if reset == True: + if reset: self.serviceNotSaved = False title = u'%s - %s' % (self.mainTitle, service_name) else: diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index b41565691..92d31842f 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -107,7 +107,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): self._clearDetails() def onStatusComboBoxChanged(self, status): - if self.programaticChange is True: + if self.programaticChange: self.programaticChange = False return self.activePlugin.toggle_status(status) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 9956023c3..d3f84a31e 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -275,7 +275,7 @@ class ThemeManager(QtGui.QWidget): def checkThemesExists(self, dir): log.debug(u'check themes') - if os.path.exists(dir) == False: + if not os.path.exists(dir): os.mkdir(dir) def unzipTheme(self, filename, dir): @@ -299,7 +299,7 @@ class ThemeManager(QtGui.QWidget): for file in zip.namelist(): if file.endswith(os.path.sep): theme_dir = os.path.join(dir, file) - if os.path.exists(theme_dir) == False: + if not os.path.exists(theme_dir): os.mkdir(os.path.join(dir, file)) else: fullpath = os.path.join(dir, file) @@ -386,7 +386,7 @@ class ThemeManager(QtGui.QWidget): """ log.debug(u'saveTheme %s %s', name, theme_xml) theme_dir = os.path.join(self.path, name) - if os.path.exists(theme_dir) == False: + if not os.path.exists(theme_dir): os.mkdir(os.path.join(self.path, name)) theme_file = os.path.join(theme_dir, name + u'.xml') log.debug(theme_file) diff --git a/openlp/plugins/bibles/lib/bibleCSVimpl.py b/openlp/plugins/bibles/lib/bibleCSVimpl.py index 1b72d1bcc..a2fed1ce5 100644 --- a/openlp/plugins/bibles/lib/bibleCSVimpl.py +++ b/openlp/plugins/bibles/lib/bibleCSVimpl.py @@ -44,17 +44,17 @@ class BibleCSVImpl(BibleCommon): QtCore.SIGNAL(u'openlpstopimport'), self.stop_import) def stop_import(self): - self.loadbible= False + self.loadbible = False def load_data(self, booksfile, versesfile, dialogobject): #Populate the Tables - fbooks=open(booksfile, 'r') - fverse=open(versesfile, 'r') + fbooks = open(booksfile, 'r') + fverse = open(versesfile, 'r') count = 0 for line in fbooks: # cancel pressed - if self.loadbible == False: + if not self.loadbible: break details = chardet.detect(line) line = unicode(line, details['encoding']) @@ -72,7 +72,7 @@ class BibleCSVImpl(BibleCommon): count = 0 book_ptr = None for line in fverse: - if self.loadbible == False: # cancel pressed + if not self.loadbible: # cancel pressed break details = chardet.detect(line) line = unicode(line, details['encoding']) diff --git a/openlp/plugins/bibles/lib/bibleOSISimpl.py b/openlp/plugins/bibles/lib/bibleOSISimpl.py index cdcea869b..04609e262 100644 --- a/openlp/plugins/bibles/lib/bibleOSISimpl.py +++ b/openlp/plugins/bibles/lib/bibleOSISimpl.py @@ -96,7 +96,7 @@ class BibleOSISImpl(): testament = 1 for file_record in osis.readlines(): # cancel pressed on UI - if self.loadbible == False: + if not self.loadbible: break pos = file_record.find(verseText) # we have a verse diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 2b987fedb..f69d14674 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -76,7 +76,7 @@ class ImageMediaItem(MediaManagerItem): self.ListView.setIconSize(QtCore.QSize(88,50)) self.servicePath = os.path.join( self.parent.config.get_data_path(), u'.thumbnails') - if os.path.exists(self.servicePath) == False: + if not os.path.exists(self.servicePath): os.mkdir(self.servicePath) self.loadList(self.parent.config.load_list(self.ConfigSection)) @@ -113,7 +113,7 @@ class ImageMediaItem(MediaManagerItem): def onDeleteClick(self): item = self.ListView.currentItem() - if item is not None: + if item: try: os.remove(os.path.join(self.servicePath, unicode(item.text()))) except: @@ -141,16 +141,17 @@ class ImageMediaItem(MediaManagerItem): def generateSlideData(self, service_item): items = self.ListView.selectedIndexes() - if len(items) == 0: + if items: + service_item.title = self.trUtf8(u'Image(s)') + for item in items: + bitem = self.ListView.item(item.row()) + filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) + frame = QtGui.QImage(unicode(filename)) + (path, name) = os.path.split(filename) + service_item.add_from_image(path, name, frame) + return True + else: return False - service_item.title = self.trUtf8(u'Image(s)') - for item in items: - bitem = self.ListView.item(item.row()) - filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) - frame = QtGui.QImage(unicode(filename)) - (path, name) = os.path.split(filename) - service_item.add_from_image(path, name, frame) - return True def toggleOverrideState(self): self.overrideActive = not self.overrideActive