openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #34338
[Merge] lp:~phill-ridout/openlp/fixes-III into lp:openlp
Phill has proposed merging lp:~phill-ridout/openlp/fixes-III into lp:openlp.
Commit message:
Minor fixes and changes
Requested reviews:
Tomas Groth (tomasgroth)
For more details, see:
https://code.launchpad.net/~phill-ridout/openlp/fixes-III/+merge/370336
--
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/common/__init__.py'
--- openlp/core/common/__init__.py 2019-07-03 06:30:01 +0000
+++ openlp/core/common/__init__.py 2019-07-18 19:17:29 +0000
@@ -45,7 +45,7 @@
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'})
@@ -103,21 +103,21 @@
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)
=== modified file 'openlp/core/common/i18n.py'
--- openlp/core/common/i18n.py 2019-06-28 18:09:25 +0000
+++ openlp/core/common/i18n.py 2019-07-18 19:17:29 +0000
@@ -338,8 +338,8 @@
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 @@
"""
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):
=== modified file 'openlp/core/lib/db.py'
--- openlp/core/lib/db.py 2019-05-22 20:46:51 +0000
+++ openlp/core/lib/db.py 2019-07-18 19:17:29 +0000
@@ -265,7 +265,7 @@
"""
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))
=== modified file 'openlp/core/lib/formattingtags.py'
--- openlp/core/lib/formattingtags.py 2019-04-13 13:00:22 +0000
+++ openlp/core/lib/formattingtags.py 2019-07-18 19:17:29 +0000
@@ -59,97 +59,98 @@
"""
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'))
=== modified file 'openlp/core/projectors/manager.py'
--- openlp/core/projectors/manager.py 2019-04-13 13:00:22 +0000
+++ openlp/core/projectors/manager.py 2019-07-18 19:17:29 +0000
@@ -344,14 +344,14 @@
"""
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]
=== modified file 'openlp/core/projectors/pjlink.py'
--- openlp/core/projectors/pjlink.py 2019-05-11 09:07:40 +0000
+++ openlp/core/projectors/pjlink.py 2019-07-18 19:17:29 +0000
@@ -552,7 +552,7 @@
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:
=== modified file 'openlp/core/projectors/sourceselectform.py'
--- openlp/core/projectors/sourceselectform.py 2019-04-13 13:00:22 +0000
+++ openlp/core/projectors/sourceselectform.py 2019-07-18 19:17:29 +0000
@@ -177,7 +177,7 @@
: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 @@
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))
=== modified file 'openlp/core/ui/__init__.py'
--- openlp/core/ui/__init__.py 2019-05-03 17:26:37 +0000
+++ openlp/core/ui/__init__.py 2019-07-18 19:17:29 +0000
@@ -93,4 +93,4 @@
self.resizeRowsToContents()
-__all__ = ['SingleColumnTableWidget', 'DisplayControllerType']
+__all__ = ['AlertLocation', 'DisplayControllerType', 'HideMode', 'SingleColumnTableWidget']
=== modified file 'openlp/core/ui/formattingtagcontroller.py'
--- openlp/core/ui/formattingtagcontroller.py 2019-06-28 18:09:25 +0000
+++ openlp/core/ui/formattingtagcontroller.py 2019-07-18 19:17:29 +0000
@@ -40,7 +40,7 @@
"""
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>!--(?:(?!-->).)*--))>')
=== modified file 'openlp/core/ui/icons.py'
--- openlp/core/ui/icons.py 2019-04-13 13:00:22 +0000
+++ openlp/core/ui/icons.py 2019-07-18 19:17:29 +0000
@@ -45,8 +45,8 @@
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 @@
'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):
"""
=== modified file 'openlp/core/ui/shortcutlistdialog.py'
--- openlp/core/ui/shortcutlistdialog.py 2019-04-13 13:00:22 +0000
+++ openlp/core/ui/shortcutlistdialog.py 2019-07-18 19:17:29 +0000
@@ -101,7 +101,7 @@
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')
=== modified file 'openlp/core/ui/shortcutlistform.py'
--- openlp/core/ui/shortcutlistform.py 2019-04-13 13:00:22 +0000
+++ openlp/core/ui/shortcutlistform.py 2019-07-18 19:17:29 +0000
@@ -34,7 +34,7 @@
from openlp.core.ui.shortcutlistdialog import Ui_ShortcutListDialog
-REMOVE_AMPERSAND = re.compile(r'&{1}')
+REMOVE_AMPERSAND = re.compile(r'&')
log = logging.getLogger(__name__)
=== modified file 'openlp/core/widgets/views.py'
--- openlp/core/widgets/views.py 2019-05-23 19:33:46 +0000
+++ openlp/core/widgets/views.py 2019-07-18 19:17:29 +0000
@@ -80,7 +80,7 @@
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 @@
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 @@
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.
=== modified file 'openlp/core/widgets/widgets.py'
--- openlp/core/widgets/widgets.py 2019-06-12 18:04:47 +0000
+++ openlp/core/widgets/widgets.py 2019-07-18 19:17:29 +0000
@@ -194,11 +194,11 @@
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)
=== modified file 'openlp/plugins/bibles/lib/manager.py'
--- openlp/plugins/bibles/lib/manager.py 2019-05-22 06:47:00 +0000
+++ openlp/plugins/bibles/lib/manager.py 2019-07-18 19:17:29 +0000
@@ -401,4 +401,4 @@
self.db_cache[bible].finalise()
-__all__ = ['BibleFormat']
+__all__ = ['BibleFormat', 'BibleManager']
=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py 2019-04-13 13:00:22 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py 2019-07-18 19:17:29 +0000
@@ -109,7 +109,7 @@
: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
=== modified file 'openlp/plugins/presentations/lib/impresscontroller.py'
--- openlp/plugins/presentations/lib/impresscontroller.py 2019-06-04 20:03:19 +0000
+++ openlp/plugins/presentations/lib/impresscontroller.py 2019-07-18 19:17:29 +0000
@@ -55,7 +55,7 @@
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 @@
except ImportError:
uno_available = False
- class SlideShowListenerImport():
+ class SlideShowListenerImport(object):
pass
log = logging.getLogger(__name__)
@@ -233,9 +233,7 @@
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 @@
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 @@
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:
=== modified file 'openlp/plugins/songs/lib/__init__.py'
--- openlp/plugins/songs/lib/__init__.py 2019-04-13 13:00:22 +0000
+++ openlp/plugins/songs/lib/__init__.py 2019-07-18 19:17:29 +0000
@@ -615,14 +615,16 @@
: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 = ''
=== modified file 'openlp/plugins/songs/lib/importers/easyworship.py'
--- openlp/plugins/songs/lib/importers/easyworship.py 2019-05-22 06:47:00 +0000
+++ openlp/plugins/songs/lib/importers/easyworship.py 2019-07-18 19:17:29 +0000
@@ -118,8 +118,8 @@
# 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':
=== modified file 'openlp/plugins/songs/lib/importers/foilpresenter.py'
--- openlp/plugins/songs/lib/importers/foilpresenter.py 2019-04-13 13:00:22 +0000
+++ openlp/plugins/songs/lib/importers/foilpresenter.py 2019-07-18 19:17:29 +0000
@@ -302,7 +302,7 @@
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:
=== modified file 'openlp/plugins/songs/lib/importers/openoffice.py'
--- openlp/plugins/songs/lib/importers/openoffice.py 2019-04-13 13:00:22 +0000
+++ openlp/plugins/songs/lib/importers/openoffice.py 2019-07-18 19:17:29 +0000
@@ -145,9 +145,7 @@
"""
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 \
=== modified file 'openlp/plugins/songs/lib/importers/opspro.py'
--- openlp/plugins/songs/lib/importers/opspro.py 2019-04-13 13:00:22 +0000
+++ openlp/plugins/songs/lib/importers/opspro.py 2019-07-18 19:17:29 +0000
@@ -136,8 +136,8 @@
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)
=== modified file 'openlp/plugins/songs/lib/importers/propresenter.py'
--- openlp/plugins/songs/lib/importers/propresenter.py 2019-05-22 06:47:00 +0000
+++ openlp/plugins/songs/lib/importers/propresenter.py 2019-07-18 19:17:29 +0000
@@ -80,7 +80,7 @@
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 @@
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 @@
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 @@
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:
=== modified file 'openlp/plugins/songs/lib/importers/videopsalm.py'
--- openlp/plugins/songs/lib/importers/videopsalm.py 2019-05-22 06:47:00 +0000
+++ openlp/plugins/songs/lib/importers/videopsalm.py 2019-07-18 19:17:29 +0000
@@ -75,7 +75,7 @@
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 == '\\':
=== modified file 'openlp/plugins/songs/lib/openlyricsxml.py'
--- openlp/plugins/songs/lib/openlyricsxml.py 2019-06-28 19:26:46 +0000
+++ openlp/plugins/songs/lib/openlyricsxml.py 2019-07-18 19:17:29 +0000
@@ -221,7 +221,7 @@
"""
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):
=== modified file 'tests/functional/openlp_core/lib/test_image_manager.py'
--- tests/functional/openlp_core/lib/test_image_manager.py 2019-04-13 13:00:22 +0000
+++ tests/functional/openlp_core/lib/test_image_manager.py 2019-07-18 19:17:29 +0000
@@ -32,7 +32,7 @@
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
=== modified file 'tests/functional/openlp_core/lib/test_theme.py'
--- tests/functional/openlp_core/lib/test_theme.py 2019-04-13 13:00:22 +0000
+++ tests/functional/openlp_core/lib/test_theme.py 2019-07-18 19:17:29 +0000
@@ -25,7 +25,78 @@
from pathlib import Path
from unittest import TestCase
-from openlp.core.lib.theme import Theme
+from openlp.core.lib.theme import BackgroundType, Theme
+
+
+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):
Follow ups