Truth tests and some style fixes

This commit is contained in:
Jon Tibble 2010-03-09 19:43:11 +00:00
parent 51d95b661c
commit e40f1b41ef
12 changed files with 33 additions and 33 deletions

View File

@ -314,7 +314,7 @@ class MediaManagerItem(QtGui.QWidget):
self, self.OnNewPrompt,
self.parent.config.get_last_dir(), self.OnNewFileMasks)
log.info(u'New files(s)%s', unicode(files))
if len(files) > 0:
if files:
self.loadList(files)
dir, filename = os.path.split(unicode(files[0]))
self.parent.config.set_last_dir(dir)

View File

@ -174,7 +174,7 @@ class Renderer(object):
#Must be a blank line so keep it.
if len(line) == 0:
line = u' '
while len(line) > 0:
while line:
pos = char_per_line
split_text = line[:pos]
#line needs splitting
@ -199,7 +199,7 @@ class Renderer(object):
split_lines.append(split_text)
line = line[pos:].lstrip()
#if we have more text add up to 10 spaces on the front.
if len(line) > 0 and self._theme.font_main_indentation > 0:
if line and self._theme.font_main_indentation > 0:
line = u'%s%s' % \
(u' '[:int(self._theme.font_main_indentation)], line)
#Text fits in a line now
@ -210,7 +210,7 @@ class Renderer(object):
len(page) == page_length:
split_pages.append(page)
page = []
if len(page) > 0 and page != u' ':
if page and page != u' ':
split_pages.append(page)
return split_pages

View File

@ -171,7 +171,8 @@ class ThemeXML(object):
self.child_element(background, u'filename', filename)
def add_font(self, name, color, proportion, override, fonttype=u'main',
weight=u'Normal', italics=u'False', indentation=0, xpos=0, ypos=0, width=0, height=0):
weight=u'Normal', italics=u'False', indentation=0, xpos=0, ypos=0,
width=0, height=0):
"""
Add a Font.
@ -363,14 +364,14 @@ class ThemeXML(object):
master = u''
for element in iter:
element.text = unicode(element.text).decode('unicode-escape')
if len(element.getchildren()) > 0:
if element.getchildren():
master = element.tag + u'_'
else:
#background transparent tags have no children so special case
if element.tag == u'background':
for e in element.attrib.iteritems():
setattr(self, element.tag + u'_' + e[0], e[1])
if len(element.attrib) > 0:
if element.attrib:
for e in element.attrib.iteritems():
if master == u'font_' and e[0] == u'type':
master += e[1] + u'_'
@ -402,4 +403,4 @@ class ThemeXML(object):
for key in dir(self):
if key[0:1] != u'_':
theme_strings.append(u'%30s: %s' % (key, getattr(self, key)))
return u'\n'.join(theme_strings)
return u'\n'.join(theme_strings)

View File

@ -428,7 +428,7 @@ class ServiceManager(QtGui.QWidget):
for itemcount, item in enumerate(self.serviceItems):
serviceitem = item[u'service_item']
treewidgetitem = QtGui.QTreeWidgetItem(self.ServiceManagerList)
if len(serviceitem.notes) > 0:
if serviceitem.notes:
icon = QtGui.QImage(serviceitem.icon)
icon = icon.scaled(80, 80, QtCore.Qt.KeepAspectRatio,
QtCore.Qt.SmoothTransformation)
@ -601,7 +601,7 @@ class ServiceManager(QtGui.QWidget):
def regenerateServiceItems(self):
#force reset of renderer as theme data has changed
self.parent.RenderManager.themedata = None
if len(self.serviceItems) > 0:
if self.serviceItems:
tempServiceItems = self.serviceItems
self.ServiceManagerList.clear()
self.serviceItems = []
@ -663,7 +663,7 @@ class ServiceManager(QtGui.QWidget):
if str_to_bool(PluginConfig(u'General').
get_config(u'auto preview', u'False')):
item += 1
if len(self.serviceItems) > 0 and item < len(self.serviceItems) and \
if self.serviceItems and item < len(self.serviceItems) and \
self.serviceItems[item][u'service_item'].autoPreviewAllowed:
self.parent.PreviewController.addServiceManagerItem(
self.serviceItems[item][u'service_item'], 0)

View File

@ -246,7 +246,7 @@ class ThemeManager(QtGui.QWidget):
self, self.trUtf8('Select Theme Import File'),
self.config.get_last_dir(), u'Theme (*.*)')
log.info(u'New Themes %s', unicode(files))
if len(files) > 0:
if files:
for file in files:
self.config.set_last_dir(unicode(file))
self.unzipTheme(file, self.path)

View File

@ -82,7 +82,7 @@ class AlertEditForm(QtGui.QDialog, Ui_AlertEditDialog):
self.DeleteButton.setEnabled(False)
def onItemSelected(self):
if len(self.AlertLineEdit.text()) > 0:
if self.AlertLineEdit.text():
QtGui.QMessageBox.information(self,
self.trUtf8('Item selected to Edit'),
self.trUtf8('Please Save or Clear seletced item'))

View File

@ -77,7 +77,7 @@ class HTTPBooks(object):
books = HTTPBooks.run_sql(u'SELECT id, testament_id, name, '
u'abbreviation, chapters FROM books WHERE name = ? OR '
u'abbreviation = ?', (name, name))
if len(books) > 0:
if books:
return {
u'id': books[0][0],
u'testament_id': books[0][1],
@ -95,7 +95,7 @@ class HTTPBooks(object):
book = HTTPBooks.get_book(name)
chapters = HTTPBooks.run_sql(u'SELECT id, book_id, chapter, '
u'verses FROM chapters WHERE book_id = ?', (book[u'id'],))
if len(chapters) > 0:
if chapters:
return {
u'id': chapters[0][0],
u'book_id': chapters[0][1],

View File

@ -254,7 +254,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
if self.VerseListView.count() == 0:
self.VerseTextEdit.setFocus()
return False, self.trUtf8('You need to enter a slide')
if len(self.VerseTextEdit.toPlainText()) > 0:
if self.VerseTextEdit.toPlainText():
self.VerseTextEdit.setFocus()
return False, self.trUtf8('You have unsaved data')
return True, u''

View File

@ -151,7 +151,7 @@ class CustomMediaItem(MediaManagerItem):
service_item.edit_enabled = True
service_item.editId = item_id
theme = customSlide.theme_name
if len(theme) is not 0 :
if theme:
service_item.theme = theme
songXML = SongXMLParser(customSlide.text)
verseList = songXML.get_verses()
@ -160,9 +160,9 @@ class CustomMediaItem(MediaManagerItem):
service_item.title = title
for slide in raw_slides:
service_item.add_from_text(slide[:30], slide)
if str_to_bool(self.parent.config.get_config(u'display footer', True)) or \
len(credit) > 0:
raw_footer.append(title + u' '+ credit)
if str_to_bool(self.parent.config.get_config(u'display footer', True)) \
or credit:
raw_footer.append(title + u' ' + credit)
else:
raw_footer.append(u'')
service_item.raw_footer = raw_footer

View File

@ -103,7 +103,7 @@ class PresentationPlugin(Plugin):
self.registerControllers(controller)
if controller.enabled:
controller.start_process()
if len(self.controllers) > 0:
if self.controllers:
return True
else:
return False

View File

@ -54,7 +54,7 @@ def main():
help="Message to be passed for the action")
(options, args) = parser.parse_args()
if len(args) > 0:
if args:
parser.print_help()
parser.error("incorrect number of arguments")
elif options.address is None:

View File

@ -153,12 +153,12 @@ class _OpenSong(XmlRootClass):
tmpVerse = []
finalLyrics = []
tag = ""
for l in lyrics:
line = l.rstrip()
for lyric in lyrics:
line = lyric.rstrip()
if not line.startswith(u'.'):
# drop all chords
tmpVerse.append(line)
if len(line) > 0:
if line:
if line.startswith(u'['):
tag = line
else:
@ -298,9 +298,9 @@ class Song(object):
chars are: .,:;!?&%#/\@`$'|"^~*-
"""
punctuation = ".,:;!?&%#'\"/\\@`$|^~*-"
s = title
for c in punctuation:
s = s.replace(c, '')
string = title
for char in punctuation:
string = string.replace(char, '')
return s
def set_title(self, title):
@ -582,17 +582,16 @@ class Song(object):
self.slideList = []
tmpSlide = []
metContent = False
for l in self.lyrics:
if len(l) > 0:
for lyric in self.lyrics:
if lyric:
metContent = True
tmpSlide.append(l)
tmpSlide.append(lyric)
else:
if metContent:
metContent = False
self.slideList.append(tmpSlide)
tmpSlide = []
#
if len(tmpSlide) > 0:
if tmpSlide:
self.slideList.append(tmpSlide)
def get_number_of_slides(self):