Minor fixes, and changes

This commit is contained in:
Phill 2019-07-03 14:23:23 +01:00
parent 28da80ecf9
commit 9c35b7dcdc
27 changed files with 219 additions and 153 deletions

View File

@ -45,7 +45,7 @@ log = logging.getLogger(__name__ + '.__init__')
FIRST_CAMEL_REGEX = re.compile('(.)([A-Z][a-z]+)')
SECOND_CAMEL_REGEX = re.compile('([a-z0-9])([A-Z])')
CONTROL_CHARS = re.compile(r'[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]')
INVALID_FILE_CHARS = re.compile(r'[\\/:\*\?"<>\|\+\[\]%]')
INVALID_FILE_CHARS = re.compile(r'[\\/:*?"<>|+\[\]%]')
IMAGES_FILTER = None
REPLACMENT_CHARS_MAP = str.maketrans({'\u2018': '\'', '\u2019': '\'', '\u201c': '"', '\u201d': '"', '\u2026': '...',
'\u2013': '-', '\u2014': '-', '\v': '\n\n', '\f': '\n\n'})
@ -112,21 +112,21 @@ def trace_error_handler(logger):
logger.error(log_string)
def extension_loader(glob_pattern, excluded_files=[]):
def extension_loader(glob_pattern, excluded_files=None):
"""
A utility function to find and load OpenLP extensions, such as plugins, presentation and media controllers and
importers.
:param str glob_pattern: A glob pattern used to find the extension(s) to be imported. Should be relative to the
application directory. i.e. plugins/*/*plugin.py
:param list[str] excluded_files: A list of file names to exclude that the glob pattern may find.
:param list[str] | None excluded_files: A list of file names to exclude that the glob pattern may find.
:rtype: None
"""
from openlp.core.common.applocation import AppLocation
app_dir = AppLocation.get_directory(AppLocation.AppDir)
for extension_path in app_dir.glob(glob_pattern):
extension_path = extension_path.relative_to(app_dir)
if extension_path.name in excluded_files:
if extension_path.name in (excluded_files or []):
continue
log.debug('Attempting to import %s', extension_path)
module_name = path_to_module(extension_path)

View File

@ -338,8 +338,8 @@ class UiStrings(object):
Override the default object creation method to return a single instance.
"""
if not cls.__instance__:
cls.__instance__ = object.__new__(cls)
cls.load(cls)
cls.__instance__ = super().__new__(cls)
cls.__instance__.load()
return cls.__instance__
def load(self):
@ -503,7 +503,7 @@ def format_time(text, local_time):
"""
return local_time.strftime(match.group())
return re.sub(r'\%[a-zA-Z]', match_formatting, text)
return re.sub(r'%[a-zA-Z]', match_formatting, text)
def get_locale_key(string, numeric=False):

View File

@ -265,7 +265,7 @@ def upgrade_db(url, upgrade):
"""
if not database_exists(url):
log.warning("Database {db} doesn't exist - skipping upgrade checks".format(db=url))
return (0, 0)
return 0, 0
log.debug('Checking upgrades for DB {db}'.format(db=url))

View File

@ -59,97 +59,98 @@ class FormattingTags(object):
"""
temporary_tags = [tag for tag in FormattingTags.html_expands if tag.get('temporary')]
FormattingTags.html_expands = []
base_tags = []
base_tags = [
{
'desc': translate('OpenLP.FormattingTags', 'Red'),
'start tag': '{r}',
'start html': '<span style="-webkit-text-fill-color:red">',
'end tag': '{/r}', 'end html': '</span>', 'protected': True,
'temporary': False
}, {
'desc': translate('OpenLP.FormattingTags', 'Black'),
'start tag': '{b}',
'start html': '<span style="-webkit-text-fill-color:black">',
'end tag': '{/b}', 'end html': '</span>', 'protected': True,
'temporary': False
}, {
'desc': translate('OpenLP.FormattingTags', 'Blue'),
'start tag': '{bl}',
'start html': '<span style="-webkit-text-fill-color:blue">',
'end tag': '{/bl}', 'end html': '</span>', 'protected': True,
'temporary': False
}, {
'desc': translate('OpenLP.FormattingTags', 'Yellow'),
'start tag': '{y}',
'start html': '<span style="-webkit-text-fill-color:yellow">',
'end tag': '{/y}', 'end html': '</span>', 'protected': True,
'temporary': False
}, {
'desc': translate('OpenLP.FormattingTags', 'Green'),
'start tag': '{g}',
'start html': '<span style="-webkit-text-fill-color:green">',
'end tag': '{/g}', 'end html': '</span>', 'protected': True,
'temporary': False
}, {
'desc': translate('OpenLP.FormattingTags', 'Pink'),
'start tag': '{pk}',
'start html': '<span style="-webkit-text-fill-color:#FFC0CB">',
'end tag': '{/pk}', 'end html': '</span>', 'protected': True,
'temporary': False
}, {
'desc': translate('OpenLP.FormattingTags', 'Orange'),
'start tag': '{o}',
'start html': '<span style="-webkit-text-fill-color:#FFA500">',
'end tag': '{/o}', 'end html': '</span>', 'protected': True,
'temporary': False
}, {
'desc': translate('OpenLP.FormattingTags', 'Purple'),
'start tag': '{pp}',
'start html': '<span style="-webkit-text-fill-color:#800080">',
'end tag': '{/pp}', 'end html': '</span>', 'protected': True,
'temporary': False
}, {
'desc': translate('OpenLP.FormattingTags', 'White'),
'start tag': '{w}',
'start html': '<span style="-webkit-text-fill-color:white">',
'end tag': '{/w}', 'end html': '</span>', 'protected': True,
'temporary': False
}, {
'desc': translate('OpenLP.FormattingTags', 'Superscript'),
'start tag': '{su}', 'start html': '<sup>',
'end tag': '{/su}', 'end html': '</sup>', 'protected': True,
'temporary': False
}, {
'desc': translate('OpenLP.FormattingTags', 'Subscript'),
'start tag': '{sb}', 'start html': '<sub>',
'end tag': '{/sb}', 'end html': '</sub>', 'protected': True,
'temporary': False
}, {
'desc': translate('OpenLP.FormattingTags', 'Paragraph'),
'start tag': '{p}', 'start html': '<p>', 'end tag': '{/p}',
'end html': '</p>', 'protected': True,
'temporary': False
}, {
'desc': translate('OpenLP.FormattingTags', 'Bold'),
'start tag': '{st}', 'start html': '<strong>',
'end tag': '{/st}', 'end html': '</strong>',
'protected': True, 'temporary': False
}, {
'desc': translate('OpenLP.FormattingTags', 'Italics'),
'start tag': '{it}', 'start html': '<em>', 'end tag': '{/it}',
'end html': '</em>', 'protected': True, 'temporary': False
}, {
'desc': translate('OpenLP.FormattingTags', 'Underline'),
'start tag': '{u}',
'start html': '<span style="text-decoration: underline;">',
'end tag': '{/u}', 'end html': '</span>', 'protected': True,
'temporary': False
}, {
'desc': translate('OpenLP.FormattingTags', 'Break'),
'start tag': '{br}', 'start html': '<br>', 'end tag': '',
'end html': '', 'protected': True,
'temporary': False
}]
# Append the base tags.
base_tags.append({
'desc': translate('OpenLP.FormattingTags', 'Red'),
'start tag': '{r}',
'start html': '<span style="-webkit-text-fill-color:red">',
'end tag': '{/r}', 'end html': '</span>', 'protected': True,
'temporary': False})
base_tags.append({
'desc': translate('OpenLP.FormattingTags', 'Black'),
'start tag': '{b}',
'start html': '<span style="-webkit-text-fill-color:black">',
'end tag': '{/b}', 'end html': '</span>', 'protected': True,
'temporary': False})
base_tags.append({
'desc': translate('OpenLP.FormattingTags', 'Blue'),
'start tag': '{bl}',
'start html': '<span style="-webkit-text-fill-color:blue">',
'end tag': '{/bl}', 'end html': '</span>', 'protected': True,
'temporary': False})
base_tags.append({
'desc': translate('OpenLP.FormattingTags', 'Yellow'),
'start tag': '{y}',
'start html': '<span style="-webkit-text-fill-color:yellow">',
'end tag': '{/y}', 'end html': '</span>', 'protected': True,
'temporary': False})
base_tags.append({
'desc': translate('OpenLP.FormattingTags', 'Green'),
'start tag': '{g}',
'start html': '<span style="-webkit-text-fill-color:green">',
'end tag': '{/g}', 'end html': '</span>', 'protected': True,
'temporary': False})
base_tags.append({
'desc': translate('OpenLP.FormattingTags', 'Pink'),
'start tag': '{pk}',
'start html': '<span style="-webkit-text-fill-color:#FFC0CB">',
'end tag': '{/pk}', 'end html': '</span>', 'protected': True,
'temporary': False})
base_tags.append({
'desc': translate('OpenLP.FormattingTags', 'Orange'),
'start tag': '{o}',
'start html': '<span style="-webkit-text-fill-color:#FFA500">',
'end tag': '{/o}', 'end html': '</span>', 'protected': True,
'temporary': False})
base_tags.append({
'desc': translate('OpenLP.FormattingTags', 'Purple'),
'start tag': '{pp}',
'start html': '<span style="-webkit-text-fill-color:#800080">',
'end tag': '{/pp}', 'end html': '</span>', 'protected': True,
'temporary': False})
base_tags.append({
'desc': translate('OpenLP.FormattingTags', 'White'),
'start tag': '{w}',
'start html': '<span style="-webkit-text-fill-color:white">',
'end tag': '{/w}', 'end html': '</span>', 'protected': True,
'temporary': False})
base_tags.append({
'desc': translate('OpenLP.FormattingTags', 'Superscript'),
'start tag': '{su}', 'start html': '<sup>',
'end tag': '{/su}', 'end html': '</sup>', 'protected': True,
'temporary': False})
base_tags.append({
'desc': translate('OpenLP.FormattingTags', 'Subscript'),
'start tag': '{sb}', 'start html': '<sub>',
'end tag': '{/sb}', 'end html': '</sub>', 'protected': True,
'temporary': False})
base_tags.append({
'desc': translate('OpenLP.FormattingTags', 'Paragraph'),
'start tag': '{p}', 'start html': '<p>', 'end tag': '{/p}',
'end html': '</p>', 'protected': True,
'temporary': False})
base_tags.append({
'desc': translate('OpenLP.FormattingTags', 'Bold'),
'start tag': '{st}', 'start html': '<strong>',
'end tag': '{/st}', 'end html': '</strong>',
'protected': True, 'temporary': False})
base_tags.append({
'desc': translate('OpenLP.FormattingTags', 'Italics'),
'start tag': '{it}', 'start html': '<em>', 'end tag': '{/it}',
'end html': '</em>', 'protected': True, 'temporary': False})
base_tags.append({
'desc': translate('OpenLP.FormattingTags', 'Underline'),
'start tag': '{u}',
'start html': '<span style="text-decoration: underline;">',
'end tag': '{/u}', 'end html': '</span>', 'protected': True,
'temporary': False})
base_tags.append({
'desc': translate('OpenLP.FormattingTags', 'Break'),
'start tag': '{br}', 'start html': '<br>', 'end tag': '',
'end html': '', 'protected': True,
'temporary': False})
FormattingTags.add_html_tags(base_tags)
FormattingTags.add_html_tags(temporary_tags)
user_expands_string = str(Settings().value('formattingTags/html_tags'))

View File

@ -344,14 +344,14 @@ class ProjectorManager(QtWidgets.QWidget, RegistryBase, UiProjectorManager, LogM
"""
log.debug('Checking for UDP port {port} listener deletion'.format(port=port))
if port not in self.pjlink_udp:
log.warn('UDP listener for port {port} not there - skipping delete'.format(port=port))
log.warning('UDP listener for port {port} not there - skipping delete'.format(port=port))
return
keep_port = False
for item in self.projector_list:
if port == item.link.port:
keep_port = True
if keep_port:
log.warn('UDP listener for port {port} needed for other projectors - skipping delete'.format(port=port))
log.warning('UDP listener for port {port} needed for other projectors - skipping delete'.format(port=port))
return
Registry().execute('udp_broadcast_remove', port=port)
del self.pjlink_udp[port]

View File

@ -552,7 +552,7 @@ class PJLink(QtNetwork.QTcpSocket):
data = data_in.strip()
self.receive_data_signal()
# Initial packet checks
if (len(data) < 7):
if len(data) < 7:
self._trash_buffer(msg='get_data(): Invalid packet - length')
return
elif len(data) > self.max_size:

View File

@ -177,7 +177,7 @@ class FingerTabBarWidget(QtWidgets.QTabBar):
:param height: Remove default height parameter in kwargs
"""
self.tabSize = QtCore.QSize(kwargs.pop('width', 100), kwargs.pop('height', 25))
QtWidgets.QTabBar.__init__(self, parent, *args, **kwargs)
super().__init__(parent)
def paintEvent(self, event):
"""
@ -215,11 +215,11 @@ class FingerTabWidget(QtWidgets.QTabWidget):
Based on thread discussion
http://www.riverbankcomputing.com/pipermail/pyqt/2005-December/011724.html
"""
def __init__(self, parent, *args):
def __init__(self, parent):
"""
Initialize FingerTabWidget instance
"""
QtWidgets.QTabWidget.__init__(self, parent, *args)
super().__init__(parent)
self.setTabBar(FingerTabBarWidget(self))

View File

@ -93,4 +93,4 @@ class SingleColumnTableWidget(QtWidgets.QTableWidget):
self.resizeRowsToContents()
__all__ = ['SingleColumnTableWidget', 'DisplayControllerType']
__all__ = ['AlertLocation', 'DisplayControllerType', 'HideMode', 'SingleColumnTableWidget']

View File

@ -40,7 +40,7 @@ class FormattingTagController(object):
"""
self.html_tag_regex = re.compile(
r'<(?:(?P<close>/(?=[^\s/>]+>))?'
r'(?P<tag>[^\s/!\?>]+)(?:\s+[^\s=]+="[^"]*")*\s*(?P<empty>/)?'
r'(?P<tag>[^\s/!?>]+)(?:\s+[^\s=]+="[^"]*")*\s*(?P<empty>/)?'
r'|(?P<cdata>!\[CDATA\[(?:(?!\]\]>).)*\]\])'
r'|(?P<procinst>\?(?:(?!\?>).)*\?)'
r'|(?P<comment>!--(?:(?!-->).)*--))>')

View File

@ -45,8 +45,8 @@ class UiIcons(object):
Override the default object creation method to return a single instance.
"""
if not cls.__instance__:
cls.__instance__ = object.__new__(cls)
cls.load(cls)
cls.__instance__ = super().__new__(cls)
cls.__instance__.load()
return cls.__instance__
def load(self):
@ -164,7 +164,7 @@ class UiIcons(object):
'video': {'icon': 'fa.file-video-o'},
'volunteer': {'icon': 'fa.group'}
}
self.load_icons(self, icon_list)
self.load_icons(icon_list)
def load_icons(self, icon_list):
"""

View File

@ -101,7 +101,7 @@ class Ui_ShortcutListDialog(object):
self.primary_push_button = CaptureShortcutButton(shortcutListDialog)
self.primary_push_button.setObjectName('primary_push_button')
self.primary_push_button.setMinimumSize(QtCore.QSize(84, 0))
self.primary_push_button.setIcon(UiIcons.shortcuts)
self.primary_push_button.setIcon(UiIcons().shortcuts)
self.primary_layout.addWidget(self.primary_push_button)
self.clear_primary_button = QtWidgets.QToolButton(shortcutListDialog)
self.clear_primary_button.setObjectName('clear_primary_button')

View File

@ -34,7 +34,7 @@ from openlp.core.common.settings import Settings
from openlp.core.ui.shortcutlistdialog import Ui_ShortcutListDialog
REMOVE_AMPERSAND = re.compile(r'&{1}')
REMOVE_AMPERSAND = re.compile(r'&')
log = logging.getLogger(__name__)

View File

@ -80,7 +80,7 @@ class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties):
An empty ``ServiceItem`` is used by default. replace_service_manager_item() needs to be called to make this
widget display something.
"""
super(QtWidgets.QTableWidget, self).__init__(parent)
super().__init__(parent)
self._setup(screen_ratio)
def _setup(self, screen_ratio):
@ -124,7 +124,7 @@ class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties):
max_img_row_height = Settings().value('advanced/slide max height')
# Adjust for row height cap if in use.
if isinstance(max_img_row_height, int):
if max_img_row_height > 0 and height > max_img_row_height:
if 0 < max_img_row_height < height:
height = max_img_row_height
elif max_img_row_height < 0:
# If auto setting, show that number of slides, or if the resulting slides too small, 100px.
@ -219,7 +219,7 @@ class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties):
slide_height = width // self.screen_ratio
max_img_row_height = Settings().value('advanced/slide max height')
if isinstance(max_img_row_height, int):
if max_img_row_height > 0 and slide_height > max_img_row_height:
if 0 < max_img_row_height < slide_height:
slide_height = max_img_row_height
elif max_img_row_height < 0:
# If auto setting, show that number of slides, or if the resulting slides too small, 100px.

View File

@ -194,11 +194,11 @@ class ScreenButton(QtWidgets.QPushButton):
class ScreenSelectionWidget(QtWidgets.QWidget):
def __init__(self, parent=None, screens=[]):
def __init__(self, parent=None, screens=None):
super().__init__(parent)
self.current_screen = None
self.identify_labels = []
self.screens = screens
self.screens = screens or []
self.timer = QtCore.QTimer()
self.timer.setSingleShot(True)
self.timer.setInterval(3000)

View File

@ -401,4 +401,4 @@ class BibleManager(LogMixin, RegistryProperties):
self.db_cache[bible].finalise()
__all__ = ['BibleFormat']
__all__ = ['BibleFormat', 'BibleManager']

View File

@ -109,7 +109,7 @@ class BibleMediaItem(MediaManagerItem):
:param kwargs: Keyword arguments to pass to the super method. (dict)
"""
self.clear_icon = UiIcons().square
self.save_results_icon = UiIcons.save
self.save_results_icon = UiIcons().save
self.sort_icon = UiIcons().sort
self.bible = None
self.second_bible = None

View File

@ -55,7 +55,7 @@ if is_win():
class SlideShowListenerImport(XSlideShowListenerObj.__class__):
pass
except (AttributeError, pywintypes.com_error):
class SlideShowListenerImport():
class SlideShowListenerImport(object):
pass
# Declare an empty exception to match the exception imported from UNO
@ -76,7 +76,7 @@ else:
except ImportError:
uno_available = False
class SlideShowListenerImport():
class SlideShowListenerImport(object):
pass
log = logging.getLogger(__name__)
@ -233,9 +233,7 @@ class ImpressController(PresentationController):
self.conf_provider = self.manager.createInstanceWithContext(
'com.sun.star.configuration.ConfigurationProvider', uno.getComponentContext())
# Setup lookup properties to get Impress settings
properties = []
properties.append(self.create_property('nodepath', 'org.openoffice.Office.Impress'))
properties = tuple(properties)
properties = tuple(self.create_property('nodepath', 'org.openoffice.Office.Impress'))
try:
# Get an updateable configuration view
impress_conf_props = self.conf_provider.createInstanceWithArguments(
@ -311,9 +309,7 @@ class ImpressDocument(PresentationDocument):
if desktop is None:
return False
self.desktop = desktop
properties = []
properties.append(self.controller.create_property('Hidden', True))
properties = tuple(properties)
properties = tuple(self.controller.create_property('Hidden', True))
try:
self.document = desktop.loadComponentFromURL(url, '_blank', 0, properties)
except Exception:
@ -338,9 +334,7 @@ class ImpressDocument(PresentationDocument):
return
temp_folder_path = self.get_temp_folder()
thumb_dir_url = temp_folder_path.as_uri()
properties = []
properties.append(self.controller.create_property('FilterName', 'impress_png_Export'))
properties = tuple(properties)
properties = tuple(self.controller.create_property('FilterName', 'impress_png_Export'))
doc = self.document
pages = doc.getDrawPages()
if not pages:

View File

@ -615,14 +615,16 @@ def transpose_chord(chord, transpose_value, notation):
:return: The transposed chord.
"""
# See https://en.wikipedia.org/wiki/Musical_note#12-tone_chromatic_scale
notes_sharp_notation = {}
notes_flat_notation = {}
notes_sharp_notation['german'] = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'H']
notes_flat_notation['german'] = ['C', 'Db', 'D', 'Eb', 'Fb', 'F', 'Gb', 'G', 'Ab', 'A', 'B', 'H']
notes_sharp_notation['english'] = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
notes_flat_notation['english'] = ['C', 'Db', 'D', 'Eb', 'Fb', 'F', 'Gb', 'G', 'Ab', 'A', 'Bb', 'B']
notes_sharp_notation['neo-latin'] = ['Do', 'Do#', 'Re', 'Re#', 'Mi', 'Fa', 'Fa#', 'Sol', 'Sol#', 'La', 'La#', 'Si']
notes_flat_notation['neo-latin'] = ['Do', 'Reb', 'Re', 'Mib', 'Fab', 'Fa', 'Solb', 'Sol', 'Lab', 'La', 'Sib', 'Si']
notes_sharp_notation = {
'german': ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'H'],
'english': ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'],
'neo-latin': ['Do', 'Do#', 'Re', 'Re#', 'Mi', 'Fa', 'Fa#', 'Sol', 'Sol#', 'La', 'La#', 'Si']
}
notes_flat_notation = {
'german': ['C', 'Db', 'D', 'Eb', 'Fb', 'F', 'Gb', 'G', 'Ab', 'A', 'B', 'H'],
'english': ['C', 'Db', 'D', 'Eb', 'Fb', 'F', 'Gb', 'G', 'Ab', 'A', 'Bb', 'B'],
'neo-latin': ['Do', 'Reb', 'Re', 'Mib', 'Fab', 'Fa', 'Solb', 'Sol', 'Lab', 'La', 'Sib', 'Si']
}
chord_split = chord.replace('', 'b').split('/')
transposed_chord = ''
last_chord = ''

View File

@ -118,8 +118,8 @@ class EasyWorshipSongImport(SongImport):
# 40/48/56 Entry count int32le 4 Number of items in the schedule
# 44/52/60 Entry length int16le 2 Length of schedule entries: 0x0718 = 1816
# Get file version
type, = struct.unpack('<38s', self.ews_file.read(38))
version = type.decode()[-3:]
file_type, = struct.unpack('<38s', self.ews_file.read(38))
version = file_type.decode()[-3:]
# Set fileposition based on filetype/version
file_pos = 0
if version == ' 5':

View File

@ -302,7 +302,7 @@ class FoilPresenter(object):
break
author_temp = []
for author in strings:
temp = re.split(r',(?=\D{2})|(?<=\D),|\/(?=\D{3,})|(?<=\D);', author)
temp = re.split(r',(?=\D{2})|(?<=\D),|/(?=\D{3,})|(?<=\D);', author)
for tempx in temp:
author_temp.append(tempx)
for author in author_temp:

View File

@ -145,9 +145,7 @@ class OpenOfficeImport(SongImport):
"""
self.file_path = file_path
url = file_path.as_uri()
properties = []
properties.append(self.create_property('Hidden', True))
properties = tuple(properties)
properties = tuple(self.create_property('Hidden', True))
try:
self.document = self.desktop.loadComponentFromURL(url, '_blank', 0, properties)
if not self.document.supportsService("com.sun.star.presentation.PresentationDocument") and not \

View File

@ -136,8 +136,8 @@ class OPSProImport(SongImport):
verse_text = re.sub(r'^\d+\r\n', '', verse_text)
verse_def = 'v' + verse_number.group(1)
# Detect verse tags
elif re.match(r'^.+?\:\r\n', verse_text):
tag_match = re.match(r'^(.+?)\:\r\n(.*)', verse_text, flags=re.DOTALL)
elif re.match(r'^.+?:\r\n', verse_text):
tag_match = re.match(r'^(.+?):\r\n(.*)', verse_text, flags=re.DOTALL)
tag = tag_match.group(1).lower()
tag = tag.split(' ')[0]
verse_text = tag_match.group(2)

View File

@ -80,7 +80,7 @@ class ProPresenterImport(SongImport):
self.parse_author(author)
# ProPresenter 4
if(self.version >= 400 and self.version < 500):
if 400 <= self.version < 500:
self.copyright = root.get('CCLICopyrightInfo')
self.ccli_number = root.get('CCLILicenseNumber')
count = 0
@ -95,7 +95,7 @@ class ProPresenterImport(SongImport):
self.add_verse(words, "v{count}".format(count=count))
# ProPresenter 5
elif(self.version >= 500 and self.version < 600):
elif 500 <= self.version < 600:
self.copyright = root.get('CCLICopyrightInfo')
self.ccli_number = root.get('CCLILicenseNumber')
count = 0
@ -111,7 +111,7 @@ class ProPresenterImport(SongImport):
self.add_verse(words, "v{count:d}".format(count=count))
# ProPresenter 6
elif(self.version >= 600 and self.version < 700):
elif 600 <= self.version < 700:
self.copyright = root.get('CCLICopyrightYear')
self.ccli_number = root.get('CCLISongNumber')
count = 0
@ -128,7 +128,7 @@ class ProPresenterImport(SongImport):
b64Data = contents.text
data = base64.standard_b64decode(b64Data)
words = None
if(contents.get('rvXMLIvarName') == "RTFData"):
if contents.get('rvXMLIvarName') == "RTFData":
words, encoding = strip_rtf(data.decode())
break
if words:

View File

@ -75,7 +75,7 @@ class VideoPsalmImport(SongImport):
c = next(file_content_it)
processed_content += '"' + c
# Remove control characters
elif (c < chr(32)):
elif c < chr(32):
processed_content += ' '
# Handle escaped characters
elif c == '\\':

View File

@ -221,7 +221,7 @@ class OpenLyrics(object):
"""
IMPLEMENTED_VERSION = '0.8'
START_TAGS_REGEX = re.compile(r'\{(\w+)\}')
END_TAGS_REGEX = re.compile(r'\{\/(\w+)\}')
END_TAGS_REGEX = re.compile(r'\{/(\w+)\}')
VERSE_TAG_SPLITTER = re.compile('([a-zA-Z]+)([0-9]*)([a-zA-Z]?)')
def __init__(self, manager):

View File

@ -32,7 +32,7 @@ from PyQt5 import QtGui
from openlp.core.common.registry import Registry
from openlp.core.display.screens import ScreenList
from openlp.core.lib.imagemanager import ImageManager, ImageWorker, Priority, PriorityQueue
from openlp.core.lib.imagemanager import Image, ImageManager, ImageWorker, Priority, PriorityQueue
from tests.helpers.testmixin import TestMixin
from tests.utils.constants import RESOURCE_PATH

View File

@ -25,7 +25,78 @@ Package to test the openlp.core.lib.theme package.
from pathlib import Path
from unittest import TestCase
from openlp.core.lib.theme import Theme
from openlp.core.lib.theme import BackgroundType
class TestBackgroundType(TestCase):
"""
Test the BackgroundType enum methods.
"""
def test_solid_to_string(self):
"""
Test the to_string method of :class:`BackgroundType`
"""
# GIVEN: A BackgroundType member
background_type = BackgroundType.Solid
# WHEN: Calling BackgroundType.to_string
# THEN: The string equivalent should have been returned
assert BackgroundType.to_string(background_type) == 'solid'
def test_gradient_to_string(self):
"""
Test the to_string method of :class:`BackgroundType`
"""
# GIVEN: A BackgroundType member
background_type = BackgroundType.Gradient
# WHEN: Calling BackgroundType.to_string
# THEN: The string equivalent should have been returned
assert BackgroundType.to_string(background_type) == 'gradient'
def test_image_to_string(self):
"""
Test the to_string method of :class:`BackgroundType`
"""
# GIVEN: A BackgroundType member
background_type = BackgroundType.Image
# WHEN: Calling BackgroundType.to_string
# THEN: The string equivalent should have been returned
assert BackgroundType.to_string(background_type) == 'image'
def test_transparent_to_string(self):
"""
Test the to_string method of :class:`BackgroundType`
"""
# GIVEN: A BackgroundType member
background_type = BackgroundType.Transparent
# WHEN: Calling BackgroundType.to_string
# THEN: The string equivalent should have been returned
assert BackgroundType.to_string(background_type) == 'transparent'
def test_video_to_string(self):
"""
Test the to_string method of :class:`BackgroundType`
"""
# GIVEN: A BackgroundType member
background_type = BackgroundType.Video
# WHEN: Calling BackgroundType.to_string
# THEN: The string equivalent should have been returned
assert BackgroundType.to_string(background_type) == 'video'
def test_stream_to_string(self):
"""
Test the to_string method of :class:`BackgroundType`
"""
# GIVEN: A BackgroundType member
background_type = BackgroundType.Stream
# WHEN: Calling BackgroundType.to_string
# THEN: The string equivalent should have been returned
assert BackgroundType.to_string(background_type) == 'stream'
class TestTheme(TestCase):