forked from openlp/openlp
More truth testing cleanup - core
This commit is contained in:
parent
51915d0e97
commit
84ce96f989
@ -110,7 +110,7 @@ def contextMenuAction(base, icon, text, slot):
|
||||
Utility method to help build context menus for plugins
|
||||
"""
|
||||
action = QtGui.QAction(text, base)
|
||||
if icon is not None:
|
||||
if icon:
|
||||
action.setIcon(buildIcon(icon))
|
||||
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot)
|
||||
return action
|
||||
|
@ -36,7 +36,7 @@ class OpenLPDockWidget(QtGui.QDockWidget):
|
||||
"""
|
||||
QtGui.QDockWidget.__init__(self, parent)
|
||||
self.parent = parent
|
||||
if name is not None:
|
||||
if name:
|
||||
self.setObjectName(name)
|
||||
self.setFloating(False)
|
||||
self.log = logging.getLogger(u'OpenLPDockWidget')
|
||||
|
@ -110,7 +110,7 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
else:
|
||||
self.icon = None
|
||||
if title is not None:
|
||||
if title:
|
||||
self.title = title
|
||||
self.Toolbar = None
|
||||
self.ServiceItemIconName = None
|
||||
@ -364,7 +364,7 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
self.trUtf8(u'You must select one or more items'))
|
||||
log.debug(self.PluginNameShort + u' Preview Requested')
|
||||
service_item = self.buildServiceItem()
|
||||
if service_item is not None:
|
||||
if service_item:
|
||||
service_item.fromPlugin = True
|
||||
self.parent.preview_controller.addServiceItem(service_item)
|
||||
|
||||
@ -375,7 +375,7 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
self.trUtf8(u'You must select one or more items'))
|
||||
log.debug(self.PluginNameShort + u' Live Requested')
|
||||
service_item = self.buildServiceItem()
|
||||
if service_item is not None:
|
||||
if service_item:
|
||||
service_item.fromPlugin = True
|
||||
service_item.uuid = unicode(uuid.uuid1())
|
||||
self.parent.live_controller.addServiceItem(service_item)
|
||||
@ -387,7 +387,7 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
self.trUtf8(u'You must select one or more items'))
|
||||
log.debug(self.PluginNameShort + u' Add Requested')
|
||||
service_item = self.buildServiceItem()
|
||||
if service_item is not None:
|
||||
if service_item:
|
||||
service_item.fromPlugin = False
|
||||
service_item.uuid = unicode(uuid.uuid1())
|
||||
self.parent.service_manager.addServiceItem(service_item)
|
||||
@ -397,7 +397,7 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
Common method for generating a service item
|
||||
"""
|
||||
service_item = ServiceItem(self.parent)
|
||||
if self.ServiceItemIconName is not None:
|
||||
if self.ServiceItemIconName:
|
||||
service_item.addIcon(self.ServiceItemIconName)
|
||||
else:
|
||||
service_item.addIcon(
|
||||
|
@ -112,7 +112,7 @@ class Plugin(QtCore.QObject):
|
||||
"""
|
||||
QtCore.QObject.__init__(self)
|
||||
self.name = name
|
||||
if version is not None:
|
||||
if version:
|
||||
self.version = version
|
||||
self.icon = None
|
||||
self.config = PluginConfig(self.name)
|
||||
@ -236,7 +236,7 @@ class Plugin(QtCore.QObject):
|
||||
"""
|
||||
Called by the plugin Manager to initialise anything it needs.
|
||||
"""
|
||||
if self.media_item is not None:
|
||||
if self.media_item:
|
||||
self.media_item.initialise()
|
||||
|
||||
def finalise(self):
|
||||
@ -256,7 +256,7 @@ class Plugin(QtCore.QObject):
|
||||
"""
|
||||
Called by plugin to replace toolbar
|
||||
"""
|
||||
if self.media_item is not None:
|
||||
if self.media_item:
|
||||
self.mediadock.insert_dock(self.media_item, self.icon, self.weight)
|
||||
if self.settings_tab is not None:
|
||||
if self.settings_tab:
|
||||
self.settings.insertTab(self.settings_tab, self.weight)
|
||||
|
@ -107,7 +107,7 @@ class PluginConfig(object):
|
||||
files = os.listdir(self.get_data_path())
|
||||
except:
|
||||
return []
|
||||
if suffix is not None:
|
||||
if suffix:
|
||||
return_files = []
|
||||
for file in files:
|
||||
if file.find(u'.') != -1:
|
||||
@ -131,7 +131,7 @@ class PluginConfig(object):
|
||||
The name of the list.
|
||||
"""
|
||||
list_count = self.get_config(u'%s count' % name)
|
||||
if list_count is not None:
|
||||
if list_count:
|
||||
list_count = int(list_count)
|
||||
else:
|
||||
list_count = 0
|
||||
@ -169,12 +169,12 @@ class PluginConfig(object):
|
||||
``num``
|
||||
Defaults to *None*. A further qualifier.
|
||||
"""
|
||||
if num is not None:
|
||||
if num:
|
||||
name = u'last directory %d' % num
|
||||
else:
|
||||
name = u'last directory'
|
||||
last_dir = self.get_config(name)
|
||||
if last_dir is None:
|
||||
if not last_dir:
|
||||
last_dir = u''
|
||||
return last_dir
|
||||
|
||||
@ -185,7 +185,7 @@ class PluginConfig(object):
|
||||
``num``
|
||||
Defaults to *None*. A further qualifier.
|
||||
"""
|
||||
if num is not None:
|
||||
if num:
|
||||
name = u'last directory %d' % num
|
||||
else:
|
||||
name = u'last directory'
|
||||
|
@ -149,8 +149,9 @@ class PluginManager(object):
|
||||
for plugin in self.plugins:
|
||||
if plugin.status is not PluginStatus.Disabled:
|
||||
plugin.settings_tab = plugin.get_settings_tab()
|
||||
if plugin.settings_tab is not None:
|
||||
log.debug(u'Inserting settings tab item from %s' % plugin.name)
|
||||
if plugin.settings_tab:
|
||||
log.debug(u'Inserting settings tab item from %s' %
|
||||
plugin.name)
|
||||
settingsform.addTab(plugin.name, plugin.settings_tab)
|
||||
else:
|
||||
log.debug(u'No tab settings in %s' % plugin.name)
|
||||
|
@ -59,7 +59,7 @@ class Renderer(object):
|
||||
``debug``
|
||||
The debug mode.
|
||||
"""
|
||||
self._debug=debug
|
||||
self._debug = debug
|
||||
|
||||
def set_theme(self, theme):
|
||||
"""
|
||||
@ -76,7 +76,7 @@ class Renderer(object):
|
||||
self.theme_name = theme.theme_name
|
||||
self._set_theme_font()
|
||||
if theme.background_type == u'image':
|
||||
if theme.background_filename is not None:
|
||||
if theme.background_filename:
|
||||
self.set_bg_image(theme.background_filename)
|
||||
|
||||
def set_bg_image(self, filename):
|
||||
@ -88,7 +88,7 @@ class Renderer(object):
|
||||
"""
|
||||
log.debug(u'set bg image %s', filename)
|
||||
self._bg_image_filename = unicode(filename)
|
||||
if self._frame is not None:
|
||||
if self._frame:
|
||||
self.scale_bg_image()
|
||||
|
||||
def scale_bg_image(self):
|
||||
@ -134,7 +134,7 @@ class Renderer(object):
|
||||
frame_height)
|
||||
self._frame = QtGui.QImage(frame_width, frame_height,
|
||||
QtGui.QImage.Format_ARGB32_Premultiplied)
|
||||
if self._bg_image_filename is not None and self.bg_image is None:
|
||||
if self._bg_image_filename and not self.bg_image:
|
||||
self.scale_bg_image()
|
||||
if self.bg_frame is None:
|
||||
self._generate_background_frame()
|
||||
@ -241,13 +241,13 @@ class Renderer(object):
|
||||
"""
|
||||
log.debug(u'generate_frame_from_lines - Start')
|
||||
bbox = self._render_lines_unaligned(lines, False)
|
||||
if footer_lines is not None:
|
||||
if footer_lines:
|
||||
bbox1 = self._render_lines_unaligned(footer_lines, True)
|
||||
# reset the frame. first time do not worry about what you paint on.
|
||||
self._frame = QtGui.QImage(self.bg_frame)
|
||||
x, y = self._correctAlignment(self._rect, bbox)
|
||||
bbox = self._render_lines_unaligned(lines, False, (x, y), True)
|
||||
if footer_lines is not None:
|
||||
if footer_lines:
|
||||
bbox = self._render_lines_unaligned(footer_lines, True,
|
||||
(self._rect_footer.left(), self._rect_footer.top()), True)
|
||||
log.debug(u'generate_frame_from_lines - Finish')
|
||||
@ -305,7 +305,7 @@ class Renderer(object):
|
||||
elif self._theme.background_type == u'image':
|
||||
# image
|
||||
painter.fillRect(self._frame.rect(), QtCore.Qt.black)
|
||||
if self.bg_image is not None:
|
||||
if self.bg_image:
|
||||
painter.drawImage(0, 0, self.bg_image)
|
||||
painter.end()
|
||||
log.debug(u'render background End')
|
||||
@ -321,13 +321,13 @@ class Renderer(object):
|
||||
Footer dimensions?
|
||||
"""
|
||||
x = rect.left()
|
||||
if int(self._theme.display_verticalAlign) == 0:
|
||||
if self._theme.display_verticalAlign == 0:
|
||||
# top align
|
||||
y = rect.top()
|
||||
elif int(self._theme.display_verticalAlign) == 2:
|
||||
elif self._theme.display_verticalAlign == 2:
|
||||
# bottom align
|
||||
y = rect.bottom() - bbox.height()
|
||||
elif int(self._theme.display_verticalAlign) == 1:
|
||||
elif self._theme.display_verticalAlign == 1:
|
||||
# centre align
|
||||
y = rect.top() + (rect.height() - bbox.height()) / 2
|
||||
else:
|
||||
@ -571,5 +571,5 @@ class Renderer(object):
|
||||
Defaults to *None*. Another image to save to disk.
|
||||
"""
|
||||
image.save(u'renderer.png', u'png')
|
||||
if image2 is not None:
|
||||
if image2:
|
||||
image2.save(u'renderer2.png', u'png')
|
||||
|
@ -121,7 +121,7 @@ class RenderManager(object):
|
||||
else:
|
||||
self.theme = self.service_theme
|
||||
else:
|
||||
if theme is not None:
|
||||
if theme:
|
||||
self.theme = theme
|
||||
elif self.global_style == u'Song' or \
|
||||
self.global_style == u'Service':
|
||||
@ -139,17 +139,19 @@ class RenderManager(object):
|
||||
self.renderer.set_theme(self.themedata)
|
||||
self.build_text_rectangle(self.themedata)
|
||||
#Replace the backgrount image from renderer with one from image
|
||||
if self.override_background is not None:
|
||||
if self.override_background:
|
||||
if self.save_bg_frame is None:
|
||||
self.save_bg_frame = self.renderer.bg_frame
|
||||
if self.override_background_changed:
|
||||
self.renderer.bg_frame = self.resize_image(self.override_background)
|
||||
self.renderer.bg_frame = self.resize_image(
|
||||
self.override_background)
|
||||
self.override_background_changed = False
|
||||
else:
|
||||
if self.override_background_changed:
|
||||
self.renderer.bg_frame = self.resize_image(self.override_background)
|
||||
self.renderer.bg_frame = self.resize_image(
|
||||
self.override_background)
|
||||
self.override_background_changed = False
|
||||
if self.save_bg_frame is not None:
|
||||
if self.save_bg_frame:
|
||||
self.renderer.bg_frame = self.save_bg_frame
|
||||
self.save_bg_frame = None
|
||||
|
||||
|
@ -57,7 +57,7 @@ class ServiceItem(object):
|
||||
The plugin that this service item belongs to.
|
||||
"""
|
||||
self.plugin = hostplugin
|
||||
if hostplugin is not None:
|
||||
if hostplugin:
|
||||
self.RenderManager = self.plugin.render_manager
|
||||
self.shortname = hostplugin.name
|
||||
self.name = self.plugin.name
|
||||
|
@ -91,7 +91,7 @@ class ThemeXML(object):
|
||||
``path``
|
||||
The path name to be added.
|
||||
"""
|
||||
if self.background_filename is not None and path is not None:
|
||||
if self.background_filename and path:
|
||||
self.theme_name = self.theme_name.rstrip().lstrip()
|
||||
self.background_filename = self.background_filename.rstrip().lstrip()
|
||||
self.background_filename = os.path.join(path, self.theme_name,
|
||||
@ -371,7 +371,7 @@ class ThemeXML(object):
|
||||
else:
|
||||
setattr(self, field, e[1])
|
||||
else:
|
||||
if element.tag is not None:
|
||||
if element.tag:
|
||||
field = master + element.tag
|
||||
if element.text == u'True' or element.text == u'False':
|
||||
setattr(self, field, str_to_bool(element.text))
|
||||
|
@ -68,12 +68,12 @@ class OpenLPToolbar(QtGui.QToolBar):
|
||||
The name of the object, as used in `<button>.setObjectName()`.
|
||||
"""
|
||||
ButtonIcon = buildIcon(icon)
|
||||
if ButtonIcon is not None:
|
||||
if slot is not None:
|
||||
if ButtonIcon:
|
||||
if slot:
|
||||
ToolbarButton = self.addAction(ButtonIcon, title, slot)
|
||||
else:
|
||||
ToolbarButton = self.addAction(ButtonIcon, title)
|
||||
if tooltip is not None:
|
||||
if tooltip:
|
||||
ToolbarButton.setToolTip(tooltip)
|
||||
self.icons[title] = ButtonIcon
|
||||
self.actions[title] = ToolbarButton
|
||||
|
@ -208,7 +208,7 @@ class MainDisplay(DisplayLabel):
|
||||
self.display.setPixmap(QtGui.QPixmap.fromImage(self.blankFrame))
|
||||
else:
|
||||
self.displayBlank = False
|
||||
if self.frame is not None:
|
||||
if self.frame:
|
||||
self.frameView(self.frame)
|
||||
if self.parent.LiveController.blackPushButton.isChecked() != \
|
||||
self.displayBlank:
|
||||
|
@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expanddock textwidth=80 dockstop=4 softdockstop=4
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
@ -54,7 +54,7 @@ class MediaDockManager(object):
|
||||
def remove_dock(self, name):
|
||||
log.debug(u'remove %s dock' % name)
|
||||
for dock_index in range(0, self.media_dock.count()):
|
||||
if self.media_dock.widget(dock_index) is not None:
|
||||
if self.media_dock.widget(dock_index):
|
||||
if self.media_dock.widget(dock_index).ConfigSection == name:
|
||||
self.media_dock.widget(dock_index).hide()
|
||||
self.media_dock.removeItem(dock_index)
|
||||
|
@ -71,7 +71,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
|
||||
status_text = 'Disabled'
|
||||
item.setText(u'%s (%s)' % (plugin.name, status_text))
|
||||
# If the plugin has an icon, set it!
|
||||
if plugin.icon is not None:
|
||||
if plugin.icon:
|
||||
item.setIcon(plugin.icon)
|
||||
self.PluginListWidget.addItem(item)
|
||||
|
||||
@ -101,7 +101,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
|
||||
if plugin.name == plugin_name:
|
||||
self.activePlugin = plugin
|
||||
break
|
||||
if self.activePlugin is not None:
|
||||
if self.activePlugin:
|
||||
self._setDetails()
|
||||
else:
|
||||
self._clearDetails()
|
||||
|
@ -246,7 +246,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
serviceIterator.setSelected(False)
|
||||
if serviceIterator.isSelected():
|
||||
#We are on the first record
|
||||
if tempItem is not None:
|
||||
if tempItem:
|
||||
tempItem.setSelected(True)
|
||||
serviceIterator.setSelected(False)
|
||||
else:
|
||||
|
@ -54,12 +54,13 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
|
||||
def insertTab(self, tab, location):
|
||||
log.debug(u'Inserting %s tab' % tab.tabTitle)
|
||||
#13 : There are 3 tables currently and locations starts at -10
|
||||
self.SettingsTabWidget.insertTab(location + 13, tab, tab.tabTitleVisible)
|
||||
self.SettingsTabWidget.insertTab(
|
||||
location + 13, tab, tab.tabTitleVisible)
|
||||
|
||||
def removeTab(self, name):
|
||||
log.debug(u'remove %s tab' % name)
|
||||
for tab_index in range(0, self.SettingsTabWidget.count()):
|
||||
if self.SettingsTabWidget.widget(tab_index) is not None:
|
||||
if self.SettingsTabWidget.widget(tab_index):
|
||||
if self.SettingsTabWidget.widget(tab_index).tabTitle == name:
|
||||
self.SettingsTabWidget.removeTab(tab_index)
|
||||
|
||||
|
@ -302,7 +302,7 @@ class SlideController(QtGui.QWidget):
|
||||
str_to_bool(self.songsconfig.get_config(u'display songbar', True)):
|
||||
for action in self.Songbar.actions:
|
||||
self.Songbar.actions[action].setVisible(False)
|
||||
if item.verse_order is not None:
|
||||
if item.verse_order:
|
||||
verses = item.verse_order.split(u' ')
|
||||
for verse in verses:
|
||||
try:
|
||||
@ -336,7 +336,7 @@ class SlideController(QtGui.QWidget):
|
||||
"""
|
||||
log.debug(u'addServiceItem')
|
||||
#If old item was a command tell it to stop
|
||||
if self.commandItem is not None and \
|
||||
if self.commandItem and \
|
||||
self.commandItem.service_item_type == ServiceItemType.Command:
|
||||
Receiver().send_message(u'%s_stop'% self.commandItem.name.lower())
|
||||
self.commandItem = item
|
||||
@ -358,7 +358,7 @@ class SlideController(QtGui.QWidget):
|
||||
"""
|
||||
Replacement item following a remote edit
|
||||
"""
|
||||
if self.commandItem is not None and \
|
||||
if self.commandItem and \
|
||||
item.uuid == self.commandItem.uuid:
|
||||
self.addServiceManagerItem(item, self.PreviewListWidget.currentRow())
|
||||
|
||||
@ -370,7 +370,7 @@ class SlideController(QtGui.QWidget):
|
||||
"""
|
||||
log.debug(u'addServiceManagerItem')
|
||||
#If old item was a command tell it to stop
|
||||
if self.commandItem is not None and \
|
||||
if self.commandItem and \
|
||||
self.commandItem.service_item_type == ServiceItemType.Command:
|
||||
Receiver().send_message(u'%s_stop'% self.commandItem.name.lower())
|
||||
self.commandItem = item
|
||||
@ -413,7 +413,7 @@ class SlideController(QtGui.QWidget):
|
||||
self.PreviewListWidget.setItem(framenumber, 0, item)
|
||||
if slide_height != 0:
|
||||
self.PreviewListWidget.setRowHeight(framenumber, slide_height)
|
||||
if self.serviceitem.frames[0][u'text'] is not None:
|
||||
if self.serviceitem.frames[0][u'text']:
|
||||
self.PreviewListWidget.resizeRowsToContents()
|
||||
self.PreviewListWidget.setColumnWidth(
|
||||
0, self.PreviewListWidget.viewport().size().width())
|
||||
@ -433,7 +433,7 @@ class SlideController(QtGui.QWidget):
|
||||
"""
|
||||
Go to the first slide.
|
||||
"""
|
||||
if self.commandItem is not None and \
|
||||
if self.commandItem and \
|
||||
self.commandItem.service_item_type == ServiceItemType.Command:
|
||||
Receiver().send_message(u'%s_first'% self.commandItem.name.lower())
|
||||
QtCore.QTimer.singleShot(0.5, self.grabMainDisplay)
|
||||
@ -445,7 +445,7 @@ class SlideController(QtGui.QWidget):
|
||||
"""
|
||||
Blank the screen.
|
||||
"""
|
||||
if self.commandItem is not None and \
|
||||
if self.commandItem and \
|
||||
self.commandItem.service_item_type == ServiceItemType.Command:
|
||||
if blanked:
|
||||
Receiver().send_message(u'%s_blank'% self.commandItem.name.lower())
|
||||
@ -499,7 +499,7 @@ class SlideController(QtGui.QWidget):
|
||||
"""
|
||||
Go to the next slide.
|
||||
"""
|
||||
if self.commandItem is not None and \
|
||||
if self.commandItem and \
|
||||
self.commandItem.service_item_type == ServiceItemType.Command:
|
||||
Receiver().send_message(u'%s_next'% self.commandItem.name.lower())
|
||||
QtCore.QTimer.singleShot(0.5, self.grabMainDisplay)
|
||||
@ -514,7 +514,7 @@ class SlideController(QtGui.QWidget):
|
||||
"""
|
||||
Go to the previous slide.
|
||||
"""
|
||||
if self.commandItem is not None and \
|
||||
if self.commandItem and \
|
||||
self.commandItem.service_item_type == ServiceItemType.Command:
|
||||
Receiver().send_message(
|
||||
u'%s_previous'% self.commandItem.name.lower())
|
||||
@ -530,7 +530,7 @@ class SlideController(QtGui.QWidget):
|
||||
"""
|
||||
Go to the last slide.
|
||||
"""
|
||||
if self.commandItem is not None and \
|
||||
if self.commandItem and \
|
||||
self.commandItem.service_item_type == ServiceItemType.Command:
|
||||
Receiver().send_message(u'%s_last'% self.commandItem.name.lower())
|
||||
QtCore.QTimer.singleShot(0.5, self.grabMainDisplay)
|
||||
|
@ -148,17 +148,18 @@ class ThemeManager(QtGui.QWidget):
|
||||
|
||||
def onEditTheme(self):
|
||||
item = self.ThemeListWidget.currentItem()
|
||||
if item is not None:
|
||||
if item:
|
||||
self.amendThemeForm.loadTheme(
|
||||
unicode(item.data(QtCore.Qt.UserRole).toString()))
|
||||
self.saveThemeName = unicode(item.data(QtCore.Qt.UserRole).toString())
|
||||
self.saveThemeName = unicode(
|
||||
item.data(QtCore.Qt.UserRole).toString())
|
||||
self.amendThemeForm.exec_()
|
||||
|
||||
def onDeleteTheme(self):
|
||||
self.global_theme = unicode(
|
||||
self.config.get_config(u'theme global theme', u''))
|
||||
item = self.ThemeListWidget.currentItem()
|
||||
if item is not None:
|
||||
if item:
|
||||
theme = unicode(item.text())
|
||||
# should be the same unless default
|
||||
if theme != unicode(item.data(QtCore.Qt.UserRole).toString()):
|
||||
@ -406,7 +407,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
outfile = open(theme_file, u'w')
|
||||
outfile.write(theme_pretty_xml)
|
||||
outfile.close()
|
||||
if image_from is not None and image_from != image_to:
|
||||
if image_from and image_from != image_to:
|
||||
print "if", image_from
|
||||
print "it", image_to
|
||||
shutil.copyfile(image_from, image_to)
|
||||
|
@ -57,7 +57,7 @@ class ConfigHelper(object):
|
||||
if reg.has_value(section, key):
|
||||
return reg.get_value(section, key, default)
|
||||
else:
|
||||
if default is not None:
|
||||
if default:
|
||||
ConfigHelper.set_config(section, key, default)
|
||||
return default
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user