forked from openlp/openlp
More truth testing cleanup - plugins
This commit is contained in:
parent
84ce96f989
commit
c2a0944e6b
@ -137,7 +137,7 @@ def main():
|
||||
log.addHandler(logfile)
|
||||
# Parse command line options and deal with them.
|
||||
(options, args) = parser.parse_args()
|
||||
if options.debug is not None:
|
||||
if options.debug:
|
||||
log.setLevel(logging.DEBUG)
|
||||
else:
|
||||
log.setLevel(logging.INFO)
|
||||
|
@ -85,7 +85,7 @@ class BiblePlugin(Plugin):
|
||||
self.ExportBibleItem.setVisible(False)
|
||||
|
||||
def onBibleNewClick(self):
|
||||
if self.media_item is not None:
|
||||
if self.media_item:
|
||||
self.media_item.onNewClick()
|
||||
|
||||
def about(self):
|
||||
|
@ -199,7 +199,7 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
|
||||
|
||||
def onImportButtonClicked(self):
|
||||
message = self.trUtf8(u'Bible import completed')
|
||||
if self.biblemanager is not None:
|
||||
if self.biblemanager:
|
||||
if not self.bible_type is None and \
|
||||
len(self.BibleNameEdit.displayText()) > 0:
|
||||
self.MessageLabel.setText(self.trUtf8(u'Import Started'))
|
||||
@ -208,7 +208,7 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
|
||||
self.ProgressBar.setValue(0)
|
||||
self.biblemanager.process_dialog(self)
|
||||
status, msg = self.importBible()
|
||||
if msg is not None:
|
||||
if msg:
|
||||
message = msg
|
||||
self.MessageLabel.setText(message)
|
||||
self.ProgressBar.setValue(self.barmax)
|
||||
|
@ -160,7 +160,7 @@ class BibleDBImpl(BibleCommon):
|
||||
everse)
|
||||
#Look up book name or abbreviation
|
||||
book = self.get_bible_book(bookname)
|
||||
if book is not None:
|
||||
if book:
|
||||
bookname = book.name
|
||||
log.debug(u'bookname corrected to %s' % bookname)
|
||||
verses = self.session.query(Verse).join(Book).filter(
|
||||
|
@ -97,7 +97,7 @@ class BibleCommon(object):
|
||||
The URL of a proxy server used to access the Internet.
|
||||
"""
|
||||
log.debug(u'get_web_text %s %s', proxyurl, urlstring)
|
||||
if proxyurl is not None:
|
||||
if proxyurl:
|
||||
proxy_support = urllib2.ProxyHandler({'http': self.proxyurl})
|
||||
http_support = urllib2.HTTPHandler()
|
||||
opener = urllib2.build_opener(proxy_support, http_support)
|
||||
|
@ -97,7 +97,7 @@ class BibleManager(object):
|
||||
# look to see if lazy load bible exists and get create getter.
|
||||
meta = self.bible_db_cache[bname].get_meta(u'proxy')
|
||||
proxy = None
|
||||
if meta is not None:
|
||||
if meta:
|
||||
proxy = meta.value
|
||||
# tell The Server where to get the verses from.
|
||||
nhttp.set_proxy(proxy)
|
||||
@ -173,14 +173,14 @@ class BibleManager(object):
|
||||
nbible.save_meta(u'WEB', biblesource)
|
||||
# store the web id of the bible
|
||||
nbible.save_meta(u'bibleid', bibleid)
|
||||
if proxyurl is not None and proxyurl != u'':
|
||||
if proxyurl and proxyurl != u'':
|
||||
# store the proxy URL
|
||||
nbible.save_meta(u'proxy', proxyurl)
|
||||
nhttp.set_proxy(proxyurl)
|
||||
if proxyid is not None and proxyid != u'':
|
||||
if proxyid and proxyid != u'':
|
||||
# store the proxy userid
|
||||
nbible.save_meta(u'proxyid', proxyid)
|
||||
if proxypass is not None and proxypass != u'':
|
||||
if proxypass and proxypass != u'':
|
||||
# store the proxy password
|
||||
nbible.save_meta(u'proxypass', proxypass)
|
||||
return True
|
||||
@ -247,7 +247,7 @@ class BibleManager(object):
|
||||
log.debug(u'get_bibles')
|
||||
bible_list = []
|
||||
for bible_name, bible_object in self.bible_db_cache.iteritems():
|
||||
if self.bible_http_cache[bible_name] is not None:
|
||||
if self.bible_http_cache[bible_name]:
|
||||
bible_name = u'%s (%s)' % (bible_name, self.web)
|
||||
bible_list.append(bible_name)
|
||||
return bible_list
|
||||
@ -338,13 +338,14 @@ class BibleManager(object):
|
||||
# check to see if book/chapter exists fow HTTP bibles and load cache
|
||||
# if necessary
|
||||
web, bible = self.is_bible_web(bible)
|
||||
if self.bible_http_cache[bible] is not None:
|
||||
if self.bible_http_cache[bible]:
|
||||
book = self.bible_db_cache[bible].get_bible_book(bookname)
|
||||
if book is None:
|
||||
log.debug(u'get_verse_text : new book')
|
||||
for chapter in range(schapter, echapter + 1):
|
||||
self.media.setQuickMessage(
|
||||
unicode(self.media.trUtf8(u'Downloading %s: %s')) % (bookname, chapter))
|
||||
unicode(self.media.trUtf8(u'Downloading %s: %s')) %
|
||||
(bookname, chapter))
|
||||
search_results = \
|
||||
self.bible_http_cache[bible].get_bible_chapter(
|
||||
bible, bookname, chapter)
|
||||
|
@ -380,7 +380,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
bible, text)
|
||||
else:
|
||||
self.searchByReference(bible, text)
|
||||
if self.search_results is not None:
|
||||
if self.search_results:
|
||||
self.displayResults(bible)
|
||||
|
||||
def generateSlideData(self, service_item):
|
||||
@ -518,9 +518,9 @@ class BibleMediaItem(MediaManagerItem):
|
||||
bible_verse.setData(QtCore.Qt.UserRole,
|
||||
QtCore.QVariant(bible_text))
|
||||
self.ListView.addItem(bible_verse)
|
||||
cr = self.ListView.setCurrentRow(count)
|
||||
if cr is not None:
|
||||
cr.setSelected(True)
|
||||
row = self.ListView.setCurrentRow(count)
|
||||
if row:
|
||||
row.setSelected(True)
|
||||
|
||||
def searchByReference(self, bible, search):
|
||||
log.debug(u'searchByReference %s, %s', bible, search)
|
||||
|
@ -90,14 +90,14 @@ class CustomMediaItem(MediaManagerItem):
|
||||
|
||||
def onRemoteEdit(self, item_id):
|
||||
valid = self.parent.custommanager.get_custom(item_id)
|
||||
if valid is not None:
|
||||
if valid:
|
||||
self.fromServiceManager = item_id
|
||||
self.parent.edit_custom_form.loadCustom(item_id)
|
||||
self.parent.edit_custom_form.exec_()
|
||||
|
||||
def onEditClick(self):
|
||||
item = self.ListView.currentItem()
|
||||
if item is not None:
|
||||
if item:
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.parent.edit_custom_form.loadCustom(item_id)
|
||||
self.parent.edit_custom_form.exec_()
|
||||
@ -105,7 +105,7 @@ class CustomMediaItem(MediaManagerItem):
|
||||
|
||||
def onDeleteClick(self):
|
||||
item = self.ListView.currentItem()
|
||||
if item is not None:
|
||||
if item:
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.parent.custommanager.delete_custom(item_id)
|
||||
row = self.ListView.row(item)
|
||||
@ -137,7 +137,7 @@ class CustomMediaItem(MediaManagerItem):
|
||||
for verse in verseList:
|
||||
raw_slides.append(verse[1])
|
||||
raw_footer.append(title + u' '+ credit)
|
||||
if theme is not None:
|
||||
if theme:
|
||||
service_item.title = title
|
||||
for slide in raw_slides:
|
||||
service_item.add_from_text(slide[:30], slide)
|
||||
|
@ -96,7 +96,7 @@ class MediaMediaItem(MediaManagerItem):
|
||||
|
||||
def onDeleteClick(self):
|
||||
item = self.ListView.currentItem()
|
||||
if item is not None:
|
||||
if item:
|
||||
row = self.ListView.row(item)
|
||||
self.ListView.takeItem(row)
|
||||
self.parent.config.set_list(
|
||||
|
@ -225,8 +225,8 @@ class ImpressController(PresentationController):
|
||||
Triggerent by new object being added to SlideController orOpenLP
|
||||
being shut down
|
||||
"""
|
||||
if self.document is not None:
|
||||
if self.presentation is not None:
|
||||
if self.document:
|
||||
if self.presentation:
|
||||
self.presentation.end()
|
||||
self.presentation = None
|
||||
self.document.dispose()
|
||||
|
@ -121,7 +121,7 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
|
||||
def onDeleteClick(self):
|
||||
item = self.ListView.currentItem()
|
||||
if item is not None:
|
||||
if item:
|
||||
row = self.ListView.row(item)
|
||||
self.ListView.takeItem(row)
|
||||
self.parent.config.set_list(
|
||||
@ -146,7 +146,7 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
cont.load_presentation(filename)
|
||||
i = 1
|
||||
img = cont.get_slide_preview_file(i)
|
||||
while img is not None:
|
||||
while img:
|
||||
service_item.add_from_command(path, name, img)
|
||||
i = i + 1
|
||||
img = cont.get_slide_preview_file(i)
|
||||
|
@ -86,7 +86,7 @@ class MessageListener(object):
|
||||
|
||||
def slide(self, message):
|
||||
self.activate()
|
||||
if message is not None:
|
||||
if message:
|
||||
self.controller.goto_slide(message[0]+1)
|
||||
self.controller.poll_slidenumber()
|
||||
|
||||
|
@ -78,7 +78,7 @@ class PptviewController(PresentationController):
|
||||
"""
|
||||
Loads the PPTVIEWLIB library
|
||||
"""
|
||||
if self.process is not None:
|
||||
if self.process:
|
||||
return
|
||||
log.debug(u'start PPTView')
|
||||
self.process = cdll.LoadLibrary(r'openlp\plugins\presentations\lib\pptviewlib\pptviewlib.dll')
|
||||
|
@ -69,7 +69,7 @@ def main():
|
||||
elif options.address is None:
|
||||
parser.print_help()
|
||||
parser.error("IP address missing")
|
||||
elif options.slidenext is not None:
|
||||
elif options.slidenext:
|
||||
options.event = u'next_slide'
|
||||
options.message = u''
|
||||
text = format_message(options)
|
||||
|
@ -55,7 +55,7 @@ class RemotesPlugin(Plugin):
|
||||
def finalise(self):
|
||||
log.debug(u'finalise')
|
||||
self.remove_toolbox_item()
|
||||
if self.server is not None:
|
||||
if self.server:
|
||||
self.server.close()
|
||||
|
||||
def get_settings_tab(self):
|
||||
|
@ -183,7 +183,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
# Not Found
|
||||
id = 0
|
||||
self.SongbookCombo.setCurrentIndex(id)
|
||||
if self.song.theme_name is not None and len(self.song.theme_name) > 0:
|
||||
if self.song.theme_name:
|
||||
id = self.ThemeSelectionComboItem.findText(
|
||||
unicode(self.song.theme_name), QtCore.Qt.MatchExactly)
|
||||
if id == -1:
|
||||
@ -193,20 +193,20 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.ThemeSelectionComboItem.setCurrentIndex(id)
|
||||
if len(title) > 1:
|
||||
self.AlternativeEdit.setText(title[1])
|
||||
if self.song.copyright is not None:
|
||||
if self.song.copyright:
|
||||
self.CopyrightEditItem.setText(self.song.copyright)
|
||||
else:
|
||||
self.CopyrightEditItem.setText(u'')
|
||||
self.VerseListWidget.clear()
|
||||
if self.song.verse_order is not None:
|
||||
if self.song.verse_order:
|
||||
self.VerseOrderEdit.setText(self.song.verse_order)
|
||||
else:
|
||||
self.VerseOrderEdit.setText(u'')
|
||||
if self.song.comments is not None:
|
||||
if self.song.comments:
|
||||
self.CommentsEdit.setPlainText(self.song.comments)
|
||||
else:
|
||||
self.CommentsEdit.setPlainText(u'')
|
||||
if self.song.ccli_number is not None:
|
||||
if self.song.ccli_number:
|
||||
self.CCLNumberEdit.setText(self.song.ccli_number)
|
||||
else:
|
||||
self.CCLNumberEdit.setText(u'')
|
||||
@ -311,7 +311,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
|
||||
def onVerseEditButtonClicked(self):
|
||||
item = self.VerseListWidget.currentItem()
|
||||
if item is not None:
|
||||
if item:
|
||||
tempText = item.text()
|
||||
self.verse_form.setVerse(tempText)
|
||||
self.verse_form.exec_()
|
||||
|
@ -68,7 +68,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
|
||||
def _getCurrentItemId(self, ListWidget):
|
||||
item = ListWidget.currentItem()
|
||||
if item is not None:
|
||||
if item:
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
return item_id
|
||||
else:
|
||||
@ -79,9 +79,10 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
item_id = self._getCurrentItemId(list_widget)
|
||||
if item_id != -1:
|
||||
item = get_func(item_id)
|
||||
if item is not None and len(item.songs) == 0:
|
||||
if item and len(item.songs) == 0:
|
||||
if QtGui.QMessageBox.warning(self, dlg_title, del_text,
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)
|
||||
QtGui.QMessageBox.StandardButtons(
|
||||
QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)
|
||||
) == QtGui.QMessageBox.Yes:
|
||||
del_func(item.id)
|
||||
reset_func()
|
||||
@ -96,7 +97,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
self.AuthorsListWidget.clear()
|
||||
authors = self.songmanager.get_authors()
|
||||
for author in authors:
|
||||
if author.display_name is not None and author.display_name != u'':
|
||||
if author.display_name:
|
||||
author_name = QtGui.QListWidgetItem(author.display_name)
|
||||
else:
|
||||
author_name = QtGui.QListWidgetItem(
|
||||
|
@ -53,11 +53,13 @@ class SongMediaItem(MediaManagerItem):
|
||||
self.edit_song_form = EditSongForm(self.parent.songmanager, self)
|
||||
self.song_maintenance_form = SongMaintenanceForm(
|
||||
self.parent.songmanager, self)
|
||||
#fromPreview holds the id of the item if the song editor needs to trigger a preview
|
||||
#without closing. It is set to -1 if this function is inactive
|
||||
# fromPreview holds the id of the item if the song editor needs to
|
||||
# trigger a preview without closing. It is set to -1 if this
|
||||
# function is inactive.
|
||||
self.fromPreview = -1
|
||||
#fromServiceManager holds the id of the item if the song editor needs to trigger posting
|
||||
#to the servicemanager without closing. It is set to -1 if this function is inactive
|
||||
# fromServiceManager holds the id of the item if the song editor needs
|
||||
# to trigger posting to the servicemanager without closing. It is set
|
||||
# to -1 if this function is inactive.
|
||||
self.fromServiceManager = -1
|
||||
|
||||
def initPluginNameVisible(self):
|
||||
@ -244,14 +246,14 @@ class SongMediaItem(MediaManagerItem):
|
||||
|
||||
def onRemoteEdit(self, songid):
|
||||
valid = self.parent.songmanager.get_song(songid)
|
||||
if valid is not None:
|
||||
if valid:
|
||||
self.fromServiceManager = songid
|
||||
self.edit_song_form.loadSong(songid, False)
|
||||
self.edit_song_form.exec_()
|
||||
|
||||
def onEditClick(self, preview=False):
|
||||
item = self.ListView.currentItem()
|
||||
if item is not None:
|
||||
if item:
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.fromPreview = -1
|
||||
if preview:
|
||||
@ -264,7 +266,7 @@ class SongMediaItem(MediaManagerItem):
|
||||
|
||||
def onDeleteClick(self):
|
||||
item = self.ListView.currentItem()
|
||||
if item is not None:
|
||||
if item:
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.parent.songmanager.delete_song(item_id)
|
||||
row = self.ListView.row(item)
|
||||
@ -295,7 +297,7 @@ class SongMediaItem(MediaManagerItem):
|
||||
songXML=SongXMLParser(song.lyrics)
|
||||
verseList = songXML.get_verses()
|
||||
for verse in verseList:
|
||||
if verse[1] is not None:
|
||||
if verse[1]:
|
||||
service_item.add_from_text(verse[1][:30], verse[1])
|
||||
else:
|
||||
verses = song.lyrics.split(u'\n\n')
|
||||
|
@ -85,7 +85,7 @@ class _OpenSong(XmlRootClass):
|
||||
def from_buffer(self, xmlContent):
|
||||
"""Initialize from buffer(string) with xml content"""
|
||||
self._reset()
|
||||
if xmlContent is not None:
|
||||
if xmlContent:
|
||||
self._setFromXml(xmlContent, 'song')
|
||||
|
||||
def get_author_list(self):
|
||||
@ -95,7 +95,7 @@ class _OpenSong(XmlRootClass):
|
||||
return as a string
|
||||
"""
|
||||
res = []
|
||||
if self.author is not None:
|
||||
if self.author:
|
||||
lst = self.author.split(u' and ')
|
||||
for l in lst:
|
||||
res.append(l.strip())
|
||||
@ -108,9 +108,9 @@ class _OpenSong(XmlRootClass):
|
||||
return as a string
|
||||
"""
|
||||
res = []
|
||||
if self.theme is not None:
|
||||
if self.theme:
|
||||
res.append(self.theme)
|
||||
if self.alttheme is not None:
|
||||
if self.alttheme:
|
||||
res.append(self.alttheme)
|
||||
s = u', u'.join(res)
|
||||
return s
|
||||
@ -264,13 +264,13 @@ class Song(object):
|
||||
"""Initialize from buffer(string) of xml lines in opensong format"""
|
||||
self._reset()
|
||||
opensong = _OpenSong(xmlcontent)
|
||||
if opensong.title is not None:
|
||||
if opensong.title:
|
||||
self.set_title(opensong.title)
|
||||
if opensong.copyright is not None:
|
||||
if opensong.copyright:
|
||||
self.set_copyright(opensong.copyright)
|
||||
if opensong.presentation is not None:
|
||||
if opensong.presentation:
|
||||
self.set_verse_order(opensong.presentation)
|
||||
if opensong.ccli is not None:
|
||||
if opensong.ccli:
|
||||
self.set_song_cclino(opensong.ccli)
|
||||
self.set_author_list(opensong.get_author_list())
|
||||
self.set_category_array(opensong.get_category_array())
|
||||
@ -402,7 +402,7 @@ class Song(object):
|
||||
def _split_to_list(self, aString):
|
||||
"""Split a string into a list - comma separated"""
|
||||
res = []
|
||||
if aString is not None:
|
||||
if aString:
|
||||
lst = aString.split(u',')
|
||||
for l in lst:
|
||||
# remove whitespace
|
||||
|
Loading…
Reference in New Issue
Block a user