Merge lp:~alisonken1/openlp/strings-lib into lp:openlp

Proposed by Ken Roberts
Status: Merged
Merged at revision: 2664
Proposed branch: lp:~alisonken1/openlp/strings-lib
Merge into: lp:openlp
Diff against target: 975 lines (+233/-125)
15 files modified
openlp/core/lib/db.py (+22/-18)
openlp/core/lib/filedialog.py (+2/-1)
openlp/core/lib/htmlbuilder.py (+51/-35)
openlp/core/lib/imagemanager.py (+3/-3)
openlp/core/lib/mediamanageritem.py (+19/-12)
openlp/core/lib/plugin.py (+5/-5)
openlp/core/lib/pluginmanager.py (+14/-11)
openlp/core/lib/renderer.py (+7/-5)
openlp/core/lib/screen.py (+9/-7)
openlp/core/lib/searchedit.py (+3/-2)
openlp/core/lib/serviceitem.py (+12/-9)
openlp/core/lib/theme.py (+2/-1)
openlp/core/lib/ui.py (+3/-3)
openlp/core/lib/webpagereader.py (+9/-9)
tests/functional/openlp_core_lib/test_projector_pjlink1.py (+72/-4)
To merge this branch: bzr merge lp:~alisonken1/openlp/strings-lib
Reviewer Review Type Date Requested Status
Tim Bentley Approve
Raoul Snyman Approve
Review via email: mp+294907@code.launchpad.net

This proposal supersedes a proposal from 2016-05-16.

Commit message

openlp/core/lib/*.py files convert strings to python3 format

Description of the change

Convert strings from python2 to python3 format

- Strings converted except as noted
- Updated projector pjlink test
- Simplify lines with multiple references to single variable

--------------------------------
lp:~alisonken1/openlp/strings-lib (revision 2665)
[SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/1559/
[SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/1470/
[SUCCESS] https://ci.openlp.io/job/Branch-03-Interface-Tests/1408/
[SUCCESS] https://ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/1188/
[SUCCESS] https://ci.openlp.io/job/Branch-04b-Windows_Interface_Tests/778/
[SUCCESS] https://ci.openlp.io/job/Branch-05a-Code_Analysis/846/
[SUCCESS] https://ci.openlp.io/job/Branch-05b-Test_Coverage/714/

To post a comment you must log in.
Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Just one question

review: Needs Information
Revision history for this message
Raoul Snyman (raoul-snyman) : Posted in a previous version of this proposal
review: Needs Fixing
Revision history for this message
Raoul Snyman (raoul-snyman) :
review: Approve
Revision history for this message
Tim Bentley (trb143) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openlp/core/lib/db.py'
--- openlp/core/lib/db.py 2016-04-05 17:10:51 +0000
+++ openlp/core/lib/db.py 2016-05-17 13:27:53 +0000
@@ -68,9 +68,11 @@
68 :return: The path to the database as type str68 :return: The path to the database as type str
69 """69 """
70 if db_file_name is None:70 if db_file_name is None:
71 return 'sqlite:///%s/%s.sqlite' % (AppLocation.get_section_data_path(plugin_name), plugin_name)71 return 'sqlite:///{path}/{plugin}.sqlite'.format(path=AppLocation.get_section_data_path(plugin_name),
72 plugin=plugin_name)
72 else:73 else:
73 return 'sqlite:///%s/%s' % (AppLocation.get_section_data_path(plugin_name), db_file_name)74 return 'sqlite:///{path}/{name}'.format(path=AppLocation.get_section_data_path(plugin_name),
75 name=db_file_name)
7476
7577
76def handle_db_error(plugin_name, db_file_name):78def handle_db_error(plugin_name, db_file_name):
@@ -82,10 +84,10 @@
82 :return: None84 :return: None
83 """85 """
84 db_path = get_db_path(plugin_name, db_file_name)86 db_path = get_db_path(plugin_name, db_file_name)
85 log.exception('Error loading database: %s', db_path)87 log.exception('Error loading database: {db}'.format(db=db_path))
86 critical_error_message_box(translate('OpenLP.Manager', 'Database Error'),88 critical_error_message_box(translate('OpenLP.Manager', 'Database Error'),
87 translate('OpenLP.Manager', 'OpenLP cannot load your database.\n\nDatabase: %s')89 translate('OpenLP.Manager',
88 % db_path)90 'OpenLP cannot load your database.\n\nDatabase: {db}').format(db=db_path))
8991
9092
91def init_url(plugin_name, db_file_name=None):93def init_url(plugin_name, db_file_name=None):
@@ -101,10 +103,11 @@
101 if db_type == 'sqlite':103 if db_type == 'sqlite':
102 db_url = get_db_path(plugin_name, db_file_name)104 db_url = get_db_path(plugin_name, db_file_name)
103 else:105 else:
104 db_url = '%s://%s:%s@%s/%s' % (db_type, urlquote(settings.value('db username')),106 db_url = '{type}://{user}:{password}@{host}/{db}'.format(type=db_type,
105 urlquote(settings.value('db password')),107 user=urlquote(settings.value('db username')),
106 urlquote(settings.value('db hostname')),108 password=urlquote(settings.value('db password')),
107 urlquote(settings.value('db database')))109 host=urlquote(settings.value('db hostname')),
110 db=urlquote(settings.value('db database')))
108 settings.endGroup()111 settings.endGroup()
109 return db_url112 return db_url
110113
@@ -157,10 +160,10 @@
157 return version, upgrade.__version__160 return version, upgrade.__version__
158 version += 1161 version += 1
159 try:162 try:
160 while hasattr(upgrade, 'upgrade_%d' % version):163 while hasattr(upgrade, 'upgrade_{version:d}'.format(version=version)):
161 log.debug('Running upgrade_%d', version)164 log.debug('Running upgrade_{version:d}'.format(version=version))
162 try:165 try:
163 upgrade_func = getattr(upgrade, 'upgrade_%d' % version)166 upgrade_func = getattr(upgrade, 'upgrade_{version:d}'.format(version=version))
164 upgrade_func(session, metadata)167 upgrade_func(session, metadata)
165 session.commit()168 session.commit()
166 # Update the version number AFTER a commit so that we are sure the previous transaction happened169 # Update the version number AFTER a commit so that we are sure the previous transaction happened
@@ -168,8 +171,8 @@
168 session.commit()171 session.commit()
169 version += 1172 version += 1
170 except (SQLAlchemyError, DBAPIError):173 except (SQLAlchemyError, DBAPIError):
171 log.exception('Could not run database upgrade script "upgrade_%s", upgrade process has been halted.',174 log.exception('Could not run database upgrade script '
172 version)175 '"upgrade_{version:d}", upgrade process has been halted.'.format(version=version))
173 break176 break
174 except (SQLAlchemyError, DBAPIError):177 except (SQLAlchemyError, DBAPIError):
175 version_meta = Metadata.populate(key='version', value=int(upgrade.__version__))178 version_meta = Metadata.populate(key='version', value=int(upgrade.__version__))
@@ -242,9 +245,10 @@
242 critical_error_message_box(245 critical_error_message_box(
243 translate('OpenLP.Manager', 'Database Error'),246 translate('OpenLP.Manager', 'Database Error'),
244 translate('OpenLP.Manager', 'The database being loaded was created in a more recent version of '247 translate('OpenLP.Manager', 'The database being loaded was created in a more recent version of '
245 'OpenLP. The database is version %d, while OpenLP expects version %d. The database will '248 'OpenLP. The database is version {db_ver}, while OpenLP expects version {db_up}. '
246 'not be loaded.\n\nDatabase: %s') % (db_ver, up_ver, self.db_url)249 'The database will not be loaded.\n\nDatabase: {db_name}').format(db_ver=db_ver,
247 )250 db_up=up_ver,
251 db_name=self.db_url))
248 return252 return
249 if not session:253 if not session:
250 try:254 try:
@@ -460,7 +464,7 @@
460 raise464 raise
461 except InvalidRequestError:465 except InvalidRequestError:
462 self.session.rollback()466 self.session.rollback()
463 log.exception('Failed to delete %s records', object_class.__name__)467 log.exception('Failed to delete {name} records'.format(name=object_class.__name__))
464 return False468 return False
465 except:469 except:
466 self.session.rollback()470 self.session.rollback()
467471
=== modified file 'openlp/core/lib/filedialog.py'
--- openlp/core/lib/filedialog.py 2015-12-31 22:46:06 +0000
+++ openlp/core/lib/filedialog.py 2016-05-17 13:27:53 +0000
@@ -50,7 +50,8 @@
50 log.info('File not found. Attempting to unquote.')50 log.info('File not found. Attempting to unquote.')
51 file = parse.unquote(file)51 file = parse.unquote(file)
52 if not os.path.exists(file):52 if not os.path.exists(file):
53 log.error('File %s not found.' % file)53 log.error('File {text} not found.'.format(text=file))
54 # TODO: Test with UiStrings() before converting to python3 strings
54 QtWidgets.QMessageBox.information(parent, UiStrings().FileNotFound,55 QtWidgets.QMessageBox.information(parent, UiStrings().FileNotFound,
55 UiStrings().FileNotFoundMessage % file)56 UiStrings().FileNotFoundMessage % file)
56 continue57 continue
5758
=== modified file 'openlp/core/lib/htmlbuilder.py'
--- openlp/core/lib/htmlbuilder.py 2015-12-31 22:46:06 +0000
+++ openlp/core/lib/htmlbuilder.py 2016-05-17 13:27:53 +0000
@@ -396,6 +396,7 @@
396396
397log = logging.getLogger(__name__)397log = logging.getLogger(__name__)
398398
399# TODO: Verify where this is used before converting to python3
399HTMLSRC = """400HTMLSRC = """
400<!DOCTYPE html>401<!DOCTYPE html>
401<html>402<html>
@@ -564,13 +565,13 @@
564 theme_data = item.theme_data565 theme_data = item.theme_data
565 # Image generated and poked in566 # Image generated and poked in
566 if background:567 if background:
567 bgimage_src = 'src="data:image/png;base64,%s"' % background568 bgimage_src = 'src="data:image/png;base64,{image}"'.format(image=background)
568 elif item.bg_image_bytes:569 elif item.bg_image_bytes:
569 bgimage_src = 'src="data:image/png;base64,%s"' % item.bg_image_bytes570 bgimage_src = 'src="data:image/png;base64,{image}"'.format(image=item.bg_image_bytes)
570 else:571 else:
571 bgimage_src = 'style="display:none;"'572 bgimage_src = 'style="display:none;"'
572 if image:573 if image:
573 image_src = 'src="data:image/png;base64,%s"' % image574 image_src = 'src="data:image/png;base64,{image}"'.format(image=image)
574 else:575 else:
575 image_src = 'style="display:none;"'576 image_src = 'style="display:none;"'
576 css_additions = ''577 css_additions = ''
@@ -601,7 +602,7 @@
601 """602 """
602 try:603 try:
603 webkit_ver = float(QtWebKit.qWebKitVersion())604 webkit_ver = float(QtWebKit.qWebKitVersion())
604 log.debug('Webkit version = %s' % webkit_ver)605 log.debug('Webkit version = {version}'.format(version=webkit_ver))
605 except AttributeError:606 except AttributeError:
606 webkit_ver = 0607 webkit_ver = 0
607 return webkit_ver608 return webkit_ver
@@ -621,23 +622,25 @@
621 if theme.background_type == BackgroundType.to_string(BackgroundType.Transparent):622 if theme.background_type == BackgroundType.to_string(BackgroundType.Transparent):
622 background = ''623 background = ''
623 elif theme.background_type == BackgroundType.to_string(BackgroundType.Solid):624 elif theme.background_type == BackgroundType.to_string(BackgroundType.Solid):
624 background = 'background-color: %s' % theme.background_color625 background = 'background-color: {theme}'.format(theme=theme.background_color)
625 else:626 else:
626 if theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Horizontal):627 if theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Horizontal):
627 background = 'background: -webkit-gradient(linear, left top, left bottom, from(%s), to(%s)) fixed' \628 background = 'background: -webkit-gradient(linear, left top, left bottom, from({start}), to({end})) ' \
628 % (theme.background_start_color, theme.background_end_color)629 'fixed'.format(start=theme.background_start_color, end=theme.background_end_color)
629 elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.LeftTop):630 elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.LeftTop):
630 background = 'background: -webkit-gradient(linear, left top, right bottom, from(%s), to(%s)) fixed' \631 background = 'background: -webkit-gradient(linear, left top, right bottom, from({start}), to({end})) ' \
631 % (theme.background_start_color, theme.background_end_color)632 'fixed'.format(start=theme.background_start_color, end=theme.background_end_color)
632 elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.LeftBottom):633 elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.LeftBottom):
633 background = 'background: -webkit-gradient(linear, left bottom, right top, from(%s), to(%s)) fixed' \634 background = 'background: -webkit-gradient(linear, left bottom, right top, from({start}), to({end})) ' \
634 % (theme.background_start_color, theme.background_end_color)635 'fixed'.format(start=theme.background_start_color, end=theme.background_end_color)
635 elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Vertical):636 elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Vertical):
636 background = 'background: -webkit-gradient(linear, left top, right top, from(%s), to(%s)) fixed' % \637 background = 'background: -webkit-gradient(linear, left top, right top, from({start}), to({end})) ' \
637 (theme.background_start_color, theme.background_end_color)638 'fixed'.format(start=theme.background_start_color, end=theme.background_end_color)
638 else:639 else:
639 background = 'background: -webkit-gradient(radial, %s 50%%, 100, %s 50%%, %s, from(%s), to(%s)) fixed'\640 background = 'background: -webkit-gradient(radial, {width} 50%, 100, {width} 50%, {width}, ' \
640 % (width, width, width, theme.background_start_color, theme.background_end_color)641 'from({start}), to({end})) fixed'.format(width=width,
642 start=theme.background_start_color,
643 end=theme.background_end_color)
641 return background644 return background
642645
643646
@@ -647,6 +650,7 @@
647650
648 :param item: Service Item containing theme and location information651 :param item: Service Item containing theme and location information
649 """652 """
653 # TODO: Verify this before converting to python3
650 style = """654 style = """
651.lyricstable {655.lyricstable {
652 z-index: 5;656 z-index: 5;
@@ -669,12 +673,13 @@
669 lyrics = ''673 lyrics = ''
670 lyricsmain = ''674 lyricsmain = ''
671 if theme_data and item.main:675 if theme_data and item.main:
672 lyricstable = 'left: %spx; top: %spx;' % (item.main.x(), item.main.y())676 lyricstable = 'left: {left}px; top: {top}px;'.format(left=item.main.x(), top=item.main.y())
673 lyrics = build_lyrics_format_css(theme_data, item.main.width(), item.main.height())677 lyrics = build_lyrics_format_css(theme_data, item.main.width(), item.main.height())
674 lyricsmain += build_lyrics_outline_css(theme_data)678 lyricsmain += build_lyrics_outline_css(theme_data)
675 if theme_data.font_main_shadow:679 if theme_data.font_main_shadow:
676 lyricsmain += ' text-shadow: %s %spx %spx;' % \680 lyricsmain += ' text-shadow: {theme} {shadow}px ' \
677 (theme_data.font_main_shadow_color, theme_data.font_main_shadow_size, theme_data.font_main_shadow_size)681 '{shadow}px;'.format(theme=theme_data.font_main_shadow_color,
682 shadow=theme_data.font_main_shadow_size)
678 lyrics_css = style % (lyricstable, lyrics, lyricsmain)683 lyrics_css = style % (lyricstable, lyrics, lyricsmain)
679 return lyrics_css684 return lyrics_css
680685
@@ -689,7 +694,9 @@
689 size = float(theme_data.font_main_outline_size) / 16694 size = float(theme_data.font_main_outline_size) / 16
690 fill_color = theme_data.font_main_color695 fill_color = theme_data.font_main_color
691 outline_color = theme_data.font_main_outline_color696 outline_color = theme_data.font_main_outline_color
692 return ' -webkit-text-stroke: %sem %s; -webkit-text-fill-color: %s; ' % (size, outline_color, fill_color)697 return ' -webkit-text-stroke: {size}em {color}; -webkit-text-fill-color: {fill}; '.format(size=size,
698 color=outline_color,
699 fill=fill_color)
693 return ''700 return ''
694701
695702
@@ -715,13 +722,21 @@
715 padding_bottom = '0.5em'722 padding_bottom = '0.5em'
716 else:723 else:
717 padding_bottom = '0'724 padding_bottom = '0'
718 lyrics = '%s word-wrap: break-word; ' \725 lyrics = '{justify} word-wrap: break-word; ' \
719 'text-align: %s; vertical-align: %s; font-family: %s; ' \726 'text-align: {align}; vertical-align: {valign}; font-family: {font}; ' \
720 'font-size: %spt; color: %s; line-height: %d%%; margin: 0;' \727 'font-size: {size}pt; color: {color}; line-height: {line:d}%; margin: 0;' \
721 'padding: 0; padding-bottom: %s; padding-left: %spx; width: %spx; height: %spx; ' % \728 'padding: 0; padding-bottom: {bottom}; padding-left: {left}px; width: {width}px; ' \
722 (justify, align, valign, theme_data.font_main_name, theme_data.font_main_size,729 'height: {height}px; '.format(justify=justify,
723 theme_data.font_main_color, 100 + int(theme_data.font_main_line_adjustment), padding_bottom,730 align=align,
724 left_margin, width, height)731 valign=valign,
732 font=theme_data.font_main_name,
733 size=theme_data.font_main_size,
734 color=theme_data.font_main_color,
735 line=100 + int(theme_data.font_main_line_adjustment),
736 bottom=padding_bottom,
737 left=left_margin,
738 width=width,
739 height=height)
725 if theme_data.font_main_italics:740 if theme_data.font_main_italics:
726 lyrics += 'font-style:italic; '741 lyrics += 'font-style:italic; '
727 if theme_data.font_main_bold:742 if theme_data.font_main_bold:
@@ -737,20 +752,21 @@
737 :param height:752 :param height:
738 """753 """
739 style = """754 style = """
740 left: %spx;755 left: {left}px;
741 bottom: %spx;756 bottom: {bottom}px;
742 width: %spx;757 width: {width}px;
743 font-family: %s;758 font-family: {family};
744 font-size: %spt;759 font-size: {size}pt;
745 color: %s;760 color: {color};
746 text-align: left;761 text-align: left;
747 white-space: %s;762 white-space: {space};
748 """763 """
749 theme = item.theme_data764 theme = item.theme_data
750 if not theme or not item.footer:765 if not theme or not item.footer:
751 return ''766 return ''
752 bottom = height - int(item.footer.y()) - int(item.footer.height())767 bottom = height - int(item.footer.y()) - int(item.footer.height())
753 whitespace = 'normal' if Settings().value('themes/wrap footer') else 'nowrap'768 whitespace = 'normal' if Settings().value('themes/wrap footer') else 'nowrap'
754 lyrics_html = style % (item.footer.x(), bottom, item.footer.width(),769 lyrics_html = style.format(left=item.footer.x(), bottom=bottom, width=item.footer.width(),
755 theme.font_footer_name, theme.font_footer_size, theme.font_footer_color, whitespace)770 family=theme.font_footer_name, size=theme.font_footer_size,
771 color=theme.font_footer_color, space=whitespace)
756 return lyrics_html772 return lyrics_html
757773
=== modified file 'openlp/core/lib/imagemanager.py'
--- openlp/core/lib/imagemanager.py 2015-12-31 22:46:06 +0000
+++ openlp/core/lib/imagemanager.py 2016-05-17 13:27:53 +0000
@@ -236,7 +236,7 @@
236 """236 """
237 Return the ``QImage`` from the cache. If not present wait for the background thread to process it.237 Return the ``QImage`` from the cache. If not present wait for the background thread to process it.
238 """238 """
239 log.debug('getImage %s' % path)239 log.debug('getImage {path}'.format(path=path))
240 image = self._cache[(path, source, width, height)]240 image = self._cache[(path, source, width, height)]
241 if image.image is None:241 if image.image is None:
242 self._conversion_queue.modify_priority(image, Priority.High)242 self._conversion_queue.modify_priority(image, Priority.High)
@@ -256,7 +256,7 @@
256 """256 """
257 Returns the byte string for an image. If not present wait for the background thread to process it.257 Returns the byte string for an image. If not present wait for the background thread to process it.
258 """258 """
259 log.debug('get_image_bytes %s' % path)259 log.debug('get_image_bytes {path}'.format(path=path))
260 image = self._cache[(path, source, width, height)]260 image = self._cache[(path, source, width, height)]
261 if image.image_bytes is None:261 if image.image_bytes is None:
262 self._conversion_queue.modify_priority(image, Priority.Urgent)262 self._conversion_queue.modify_priority(image, Priority.Urgent)
@@ -271,7 +271,7 @@
271 """271 """
272 Add image to cache if it is not already there.272 Add image to cache if it is not already there.
273 """273 """
274 log.debug('add_image %s' % path)274 log.debug('add_image {path}'.format(path=path))
275 if not (path, source, width, height) in self._cache:275 if not (path, source, width, height) in self._cache:
276 image = Image(path, source, background, width, height)276 image = Image(path, source, background, width, height)
277 self._cache[(path, source, width, height)] = image277 self._cache[(path, source, width, height)] = image
278278
=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py 2016-04-17 19:32:15 +0000
+++ openlp/core/lib/mediamanageritem.py 2016-05-17 13:27:53 +0000
@@ -186,7 +186,7 @@
186 for action in toolbar_actions:186 for action in toolbar_actions:
187 if action[0] == StringContent.Preview:187 if action[0] == StringContent.Preview:
188 self.toolbar.addSeparator()188 self.toolbar.addSeparator()
189 self.toolbar.add_toolbar_action('%s%sAction' % (self.plugin.name, action[0]),189 self.toolbar.add_toolbar_action('{name}{action}Action'.format(name=self.plugin.name, action=action[0]),
190 text=self.plugin.get_string(action[1])['title'], icon=action[2],190 text=self.plugin.get_string(action[1])['title'], icon=action[2],
191 tooltip=self.plugin.get_string(action[1])['tooltip'],191 tooltip=self.plugin.get_string(action[1])['tooltip'],
192 triggers=action[3])192 triggers=action[3])
@@ -200,7 +200,7 @@
200 self.list_view.setSpacing(1)200 self.list_view.setSpacing(1)
201 self.list_view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)201 self.list_view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
202 self.list_view.setAlternatingRowColors(True)202 self.list_view.setAlternatingRowColors(True)
203 self.list_view.setObjectName('%sListView' % self.plugin.name)203 self.list_view.setObjectName('{name}ListView'.format(name=self.plugin.name))
204 # Add to page_layout204 # Add to page_layout
205 self.page_layout.addWidget(self.list_view)205 self.page_layout.addWidget(self.list_view)
206 # define and add the context menu206 # define and add the context menu
@@ -212,19 +212,22 @@
212 triggers=self.on_edit_click)212 triggers=self.on_edit_click)
213 create_widget_action(self.list_view, separator=True)213 create_widget_action(self.list_view, separator=True)
214 create_widget_action(self.list_view,214 create_widget_action(self.list_view,
215 'listView%s%sItem' % (self.plugin.name.title(), StringContent.Preview.title()),215 'listView{plugin}{preview}Item'.format(plugin=self.plugin.name.title(),
216 preview=StringContent.Preview.title()),
216 text=self.plugin.get_string(StringContent.Preview)['title'],217 text=self.plugin.get_string(StringContent.Preview)['title'],
217 icon=':/general/general_preview.png',218 icon=':/general/general_preview.png',
218 can_shortcuts=True,219 can_shortcuts=True,
219 triggers=self.on_preview_click)220 triggers=self.on_preview_click)
220 create_widget_action(self.list_view,221 create_widget_action(self.list_view,
221 'listView%s%sItem' % (self.plugin.name.title(), StringContent.Live.title()),222 'listView{plugin}{live}Item'.format(plugin=self.plugin.name.title(),
223 live=StringContent.Live.title()),
222 text=self.plugin.get_string(StringContent.Live)['title'],224 text=self.plugin.get_string(StringContent.Live)['title'],
223 icon=':/general/general_live.png',225 icon=':/general/general_live.png',
224 can_shortcuts=True,226 can_shortcuts=True,
225 triggers=self.on_live_click)227 triggers=self.on_live_click)
226 create_widget_action(self.list_view,228 create_widget_action(self.list_view,
227 'listView%s%sItem' % (self.plugin.name.title(), StringContent.Service.title()),229 'listView{plugin}{service}Item'.format(plugin=self.plugin.name.title(),
230 service=StringContent.Service.title()),
228 can_shortcuts=True,231 can_shortcuts=True,
229 text=self.plugin.get_string(StringContent.Service)['title'],232 text=self.plugin.get_string(StringContent.Service)['title'],
230 icon=':/general/general_add.png',233 icon=':/general/general_add.png',
@@ -232,7 +235,8 @@
232 if self.has_delete_icon:235 if self.has_delete_icon:
233 create_widget_action(self.list_view, separator=True)236 create_widget_action(self.list_view, separator=True)
234 create_widget_action(self.list_view,237 create_widget_action(self.list_view,
235 'listView%s%sItem' % (self.plugin.name.title(), StringContent.Delete.title()),238 'listView{plugin}{delete}Item'.format(plugin=self.plugin.name.title(),
239 delete=StringContent.Delete.title()),
236 text=self.plugin.get_string(StringContent.Delete)['title'],240 text=self.plugin.get_string(StringContent.Delete)['title'],
237 icon=':/general/general_delete.png',241 icon=':/general/general_delete.png',
238 can_shortcuts=True, triggers=self.on_delete_click)242 can_shortcuts=True, triggers=self.on_delete_click)
@@ -313,7 +317,7 @@
313 files = FileDialog.getOpenFileNames(self, self.on_new_prompt,317 files = FileDialog.getOpenFileNames(self, self.on_new_prompt,
314 Settings().value(self.settings_section + '/last directory'),318 Settings().value(self.settings_section + '/last directory'),
315 self.on_new_file_masks)319 self.on_new_file_masks)
316 log.info('New files(s) %s' % files)320 log.info('New files(s) {files}'.format(files=files))
317 if files:321 if files:
318 self.application.set_busy_cursor()322 self.application.set_busy_cursor()
319 self.validate_and_load(files)323 self.validate_and_load(files)
@@ -333,7 +337,8 @@
333 if not error_shown:337 if not error_shown:
334 critical_error_message_box(translate('OpenLP.MediaManagerItem', 'Invalid File Type'),338 critical_error_message_box(translate('OpenLP.MediaManagerItem', 'Invalid File Type'),
335 translate('OpenLP.MediaManagerItem',339 translate('OpenLP.MediaManagerItem',
336 'Invalid File %s.\nSuffix not supported') % file_name)340 'Invalid File {name}.\n'
341 'Suffix not supported').format(name=file_name))
337 error_shown = True342 error_shown = True
338 else:343 else:
339 new_files.append(file_name)344 new_files.append(file_name)
@@ -375,7 +380,8 @@
375 self.load_list(full_list, target_group)380 self.load_list(full_list, target_group)
376 last_dir = os.path.split(files[0])[0]381 last_dir = os.path.split(files[0])[0]
377 Settings().setValue(self.settings_section + '/last directory', last_dir)382 Settings().setValue(self.settings_section + '/last directory', last_dir)
378 Settings().setValue('%s/%s files' % (self.settings_section, self.settings_section), self.get_file_list())383 Settings().setValue('{section}/{section} files'.format(section=self.settings_section),
384 self.get_file_list())
379 if duplicates_found:385 if duplicates_found:
380 critical_error_message_box(UiStrings().Duplicate,386 critical_error_message_box(UiStrings().Duplicate,
381 translate('OpenLP.MediaManagerItem',387 translate('OpenLP.MediaManagerItem',
@@ -550,7 +556,7 @@
550 # Is it possible to process multiple list items to generate556 # Is it possible to process multiple list items to generate
551 # multiple service items?557 # multiple service items?
552 if self.single_service_item:558 if self.single_service_item:
553 log.debug('%s Add requested', self.plugin.name)559 log.debug('{plugin} Add requested'.format(plugin=self.plugin.name))
554 self.add_to_service(replace=self.remote_triggered)560 self.add_to_service(replace=self.remote_triggered)
555 else:561 else:
556 items = self.list_view.selectedIndexes()562 items = self.list_view.selectedIndexes()
@@ -591,7 +597,7 @@
591 translate('OpenLP.MediaManagerItem',597 translate('OpenLP.MediaManagerItem',
592 'You must select one or more items.'))598 'You must select one or more items.'))
593 else:599 else:
594 log.debug('%s Add requested', self.plugin.name)600 log.debug('{plugin} Add requested'.format(plugin=self.plugin.name))
595 service_item = self.service_manager.get_service_item()601 service_item = self.service_manager.get_service_item()
596 if not service_item:602 if not service_item:
597 QtWidgets.QMessageBox.information(self, UiStrings().NISs,603 QtWidgets.QMessageBox.information(self, UiStrings().NISs,
@@ -604,7 +610,8 @@
604 # Turn off the remote edit update message indicator610 # Turn off the remote edit update message indicator
605 QtWidgets.QMessageBox.information(self, translate('OpenLP.MediaManagerItem', 'Invalid Service Item'),611 QtWidgets.QMessageBox.information(self, translate('OpenLP.MediaManagerItem', 'Invalid Service Item'),
606 translate('OpenLP.MediaManagerItem',612 translate('OpenLP.MediaManagerItem',
607 'You must select a %s service item.') % self.title)613 'You must select a {title} '
614 'service item.').format(title=self.title))
608615
609 def build_service_item(self, item=None, xml_version=False, remote=False, context=ServiceItemContext.Live):616 def build_service_item(self, item=None, xml_version=False, remote=False, context=ServiceItemContext.Live):
610 """617 """
611618
=== modified file 'openlp/core/lib/plugin.py'
--- openlp/core/lib/plugin.py 2016-04-04 19:53:54 +0000
+++ openlp/core/lib/plugin.py 2016-05-17 13:27:53 +0000
@@ -130,7 +130,7 @@
130 :param settings_tab_class: The class name of the plugin's settings tab.130 :param settings_tab_class: The class name of the plugin's settings tab.
131 :param version: Defaults to *None*, which means that the same version number is used as OpenLP's version number.131 :param version: Defaults to *None*, which means that the same version number is used as OpenLP's version number.
132 """132 """
133 log.debug('Plugin %s initialised' % name)133 log.debug('Plugin {plugin} initialised'.format(plugin=name))
134 super(Plugin, self).__init__()134 super(Plugin, self).__init__()
135 self.name = name135 self.name = name
136 self.text_strings = {}136 self.text_strings = {}
@@ -154,11 +154,11 @@
154 # Append a setting for files in the mediamanager (note not all plugins154 # Append a setting for files in the mediamanager (note not all plugins
155 # which have a mediamanager need this).155 # which have a mediamanager need this).
156 if media_item_class is not None:156 if media_item_class is not None:
157 default_settings['%s/%s files' % (name, name)] = []157 default_settings['{name}/{name} files'.format(name=name)] = []
158 # Add settings to the dict of all settings.158 # Add settings to the dict of all settings.
159 Settings.extend_default_settings(default_settings)159 Settings.extend_default_settings(default_settings)
160 Registry().register_function('%s_add_service_item' % self.name, self.process_add_service_event)160 Registry().register_function('{name}_add_service_item'.format(name=self.name), self.process_add_service_event)
161 Registry().register_function('%s_config_updated' % self.name, self.config_update)161 Registry().register_function('{name}_config_updated'.format(name=self.name), self.config_update)
162162
163 def check_pre_conditions(self):163 def check_pre_conditions(self):
164 """164 """
@@ -256,7 +256,7 @@
256 """256 """
257 Generic Drag and drop handler triggered from service_manager.257 Generic Drag and drop handler triggered from service_manager.
258 """258 """
259 log.debug('process_add_service_event event called for plugin %s' % self.name)259 log.debug('process_add_service_event event called for plugin {name}'.format(name=self.name))
260 if replace:260 if replace:
261 self.media_item.on_add_edit_click()261 self.media_item.on_add_edit_click()
262 else:262 else:
263263
=== modified file 'openlp/core/lib/pluginmanager.py'
--- openlp/core/lib/pluginmanager.py 2015-12-31 22:46:06 +0000
+++ openlp/core/lib/pluginmanager.py 2016-05-17 13:27:53 +0000
@@ -43,7 +43,7 @@
43 super(PluginManager, self).__init__(parent)43 super(PluginManager, self).__init__(parent)
44 self.log_info('Plugin manager Initialising')44 self.log_info('Plugin manager Initialising')
45 self.base_path = os.path.abspath(AppLocation.get_directory(AppLocation.PluginsDir))45 self.base_path = os.path.abspath(AppLocation.get_directory(AppLocation.PluginsDir))
46 self.log_debug('Base path %s ' % self.base_path)46 self.log_debug('Base path {path}'.format(path=self.base_path))
47 self.plugins = []47 self.plugins = []
48 self.log_info('Plugin manager Initialised')48 self.log_info('Plugin manager Initialised')
4949
@@ -73,7 +73,7 @@
73 """73 """
74 start_depth = len(os.path.abspath(self.base_path).split(os.sep))74 start_depth = len(os.path.abspath(self.base_path).split(os.sep))
75 present_plugin_dir = os.path.join(self.base_path, 'presentations')75 present_plugin_dir = os.path.join(self.base_path, 'presentations')
76 self.log_debug('finding plugins in %s at depth %d' % (self.base_path, start_depth))76 self.log_debug('finding plugins in {path} at depth {depth:d}'.format(path=self.base_path, depth=start_depth))
77 for root, dirs, files in os.walk(self.base_path):77 for root, dirs, files in os.walk(self.base_path):
78 for name in files:78 for name in files:
79 if name.endswith('.py') and not name.startswith('__'):79 if name.endswith('.py') and not name.startswith('__'):
@@ -84,7 +84,9 @@
84 break84 break
85 module_name = name[:-3]85 module_name = name[:-3]
86 # import the modules86 # import the modules
87 self.log_debug('Importing %s from %s. Depth %d' % (module_name, root, this_depth))87 self.log_debug('Importing {name} from {root}. Depth {depth:d}'.format(name=module_name,
88 root=root,
89 depth=this_depth))
88 try:90 try:
89 # Use the "imp" library to try to get around a problem with the PyUNO library which91 # Use the "imp" library to try to get around a problem with the PyUNO library which
90 # monkey-patches the __import__ function to do some magic. This causes issues with our tests.92 # monkey-patches the __import__ function to do some magic. This causes issues with our tests.
@@ -93,21 +95,21 @@
93 # Then load the module (do the actual import) using the details from find_module()95 # Then load the module (do the actual import) using the details from find_module()
94 imp.load_module(module_name, fp, path_name, description)96 imp.load_module(module_name, fp, path_name, description)
95 except ImportError as e:97 except ImportError as e:
96 self.log_exception('Failed to import module %s on path %s: %s'98 self.log_exception('Failed to import module {name} on path {path}: '
97 % (module_name, path, e.args[0]))99 '{args}'.format(name=module_name, path=path, args=e.args[0]))
98 plugin_classes = Plugin.__subclasses__()100 plugin_classes = Plugin.__subclasses__()
99 plugin_objects = []101 plugin_objects = []
100 for p in plugin_classes:102 for p in plugin_classes:
101 try:103 try:
102 plugin = p()104 plugin = p()
103 self.log_debug('Loaded plugin %s' % str(p))105 self.log_debug('Loaded plugin {plugin}'.format(plugin=str(p)))
104 plugin_objects.append(plugin)106 plugin_objects.append(plugin)
105 except TypeError:107 except TypeError:
106 self.log_exception('Failed to load plugin %s' % str(p))108 self.log_exception('Failed to load plugin {plugin}'.format(plugin=str(p)))
107 plugins_list = sorted(plugin_objects, key=lambda plugin: plugin.weight)109 plugins_list = sorted(plugin_objects, key=lambda plugin: plugin.weight)
108 for plugin in plugins_list:110 for plugin in plugins_list:
109 if plugin.check_pre_conditions():111 if plugin.check_pre_conditions():
110 self.log_debug('Plugin %s active' % str(plugin.name))112 self.log_debug('Plugin {plugin} active'.format(plugin=str(plugin.name)))
111 plugin.set_status()113 plugin.set_status()
112 else:114 else:
113 plugin.status = PluginStatus.Disabled115 plugin.status = PluginStatus.Disabled
@@ -175,10 +177,11 @@
175 Loop through all the plugins and give them an opportunity to initialise themselves.177 Loop through all the plugins and give them an opportunity to initialise themselves.
176 """178 """
177 for plugin in self.plugins:179 for plugin in self.plugins:
178 self.log_info('initialising plugins %s in a %s state' % (plugin.name, plugin.is_active()))180 self.log_info('initialising plugins {plugin} in a {state} state'.format(plugin=plugin.name,
181 state=plugin.is_active()))
179 if plugin.is_active():182 if plugin.is_active():
180 plugin.initialise()183 plugin.initialise()
181 self.log_info('Initialisation Complete for %s ' % plugin.name)184 self.log_info('Initialisation Complete for {plugin}'.format(plugin=plugin.name))
182185
183 def finalise_plugins(self):186 def finalise_plugins(self):
184 """187 """
@@ -187,7 +190,7 @@
187 for plugin in self.plugins:190 for plugin in self.plugins:
188 if plugin.is_active():191 if plugin.is_active():
189 plugin.finalise()192 plugin.finalise()
190 self.log_info('Finalisation Complete for %s ' % plugin.name)193 self.log_info('Finalisation Complete for {plugin}'.format(plugin=plugin.name))
191194
192 def get_plugin_by_name(self, name):195 def get_plugin_by_name(self, name):
193 """196 """
194197
=== modified file 'openlp/core/lib/renderer.py'
--- openlp/core/lib/renderer.py 2016-01-23 12:38:08 +0000
+++ openlp/core/lib/renderer.py 2016-05-17 13:27:53 +0000
@@ -107,7 +107,7 @@
107107
108 :param theme_name: The theme name108 :param theme_name: The theme name
109 """109 """
110 self.log_debug("_set_theme with theme %s" % theme_name)110 self.log_debug("_set_theme with theme {theme}".format(theme=theme_name))
111 if theme_name not in self._theme_dimensions:111 if theme_name not in self._theme_dimensions:
112 theme_data = self.theme_manager.get_theme_data(theme_name)112 theme_data = self.theme_manager.get_theme_data(theme_name)
113 main_rect = self.get_main_rectangle(theme_data)113 main_rect = self.get_main_rectangle(theme_data)
@@ -183,7 +183,7 @@
183183
184 :param item_theme_name: The item theme's name.184 :param item_theme_name: The item theme's name.
185 """185 """
186 self.log_debug("set_item_theme with theme %s" % item_theme_name)186 self.log_debug("set_item_theme with theme {theme}".format(theme=item_theme_name))
187 self._set_theme(item_theme_name)187 self._set_theme(item_theme_name)
188 self.item_theme_name = item_theme_name188 self.item_theme_name = item_theme_name
189189
@@ -317,7 +317,7 @@
317 self.width = screen_size.width()317 self.width = screen_size.width()
318 self.height = screen_size.height()318 self.height = screen_size.height()
319 self.screen_ratio = self.height / self.width319 self.screen_ratio = self.height / self.width
320 self.log_debug('_calculate default %s, %f' % (screen_size, self.screen_ratio))320 self.log_debug('_calculate default {size}, {ratio:f}'.format(size=screen_size, ratio=self.screen_ratio))
321 # 90% is start of footer321 # 90% is start of footer
322 self.footer_start = int(self.height * 0.90)322 self.footer_start = int(self.height * 0.90)
323323
@@ -354,7 +354,7 @@
354 :param rect_main: The main text block.354 :param rect_main: The main text block.
355 :param rect_footer: The footer text block.355 :param rect_footer: The footer text block.
356 """356 """
357 self.log_debug('_set_text_rectangle %s , %s' % (rect_main, rect_footer))357 self.log_debug('_set_text_rectangle {main} , {footer}'.format(main=rect_main, footer=rect_footer))
358 self._rect = rect_main358 self._rect = rect_main
359 self._rect_footer = rect_footer359 self._rect_footer = rect_footer
360 self.page_width = self._rect.width()360 self.page_width = self._rect.width()
@@ -370,6 +370,7 @@
370 self.web.resize(self.page_width, self.page_height)370 self.web.resize(self.page_width, self.page_height)
371 self.web_frame = self.web.page().mainFrame()371 self.web_frame = self.web.page().mainFrame()
372 # Adjust width and height to account for shadow. outline done in css.372 # Adjust width and height to account for shadow. outline done in css.
373 # TODO: Verify before converting to python3 strings
373 html = """<!DOCTYPE html><html><head><script>374 html = """<!DOCTYPE html><html><head><script>
374 function show_text(newtext) {375 function show_text(newtext) {
375 var main = document.getElementById('main');376 var main = document.getElementById('main');
@@ -518,7 +519,8 @@
518519
519 :param text: The text to check. It may contain HTML tags.520 :param text: The text to check. It may contain HTML tags.
520 """521 """
521 self.web_frame.evaluateJavaScript('show_text("%s")' % text.replace('\\', '\\\\').replace('\"', '\\\"'))522 self.web_frame.evaluateJavaScript('show_text'
523 '("{text}")'.format(text=text.replace('\\', '\\\\').replace('\"', '\\\"')))
522 return self.web_frame.contentsSize().height() <= self.empty_height524 return self.web_frame.contentsSize().height() <= self.empty_height
523525
524526
525527
=== modified file 'openlp/core/lib/screen.py'
--- openlp/core/lib/screen.py 2016-01-10 16:00:05 +0000
+++ openlp/core/lib/screen.py 2016-05-17 13:27:53 +0000
@@ -78,7 +78,7 @@
78 ``number``78 ``number``
79 The number of the screen, which size has changed.79 The number of the screen, which size has changed.
80 """80 """
81 log.info('screen_resolution_changed %d' % number)81 log.info('screen_resolution_changed {number:d}'.format(number=number))
82 for screen in self.screen_list:82 for screen in self.screen_list:
83 if number == screen['number']:83 if number == screen['number']:
84 new_screen = {84 new_screen = {
@@ -105,7 +105,7 @@
105 """105 """
106 # Do not log at start up.106 # Do not log at start up.
107 if changed_screen != -1:107 if changed_screen != -1:
108 log.info('screen_count_changed %d' % self.desktop.screenCount())108 log.info('screen_count_changed {count:d}'.format(count=self.desktop.screenCount()))
109 # Remove unplugged screens.109 # Remove unplugged screens.
110 for screen in copy.deepcopy(self.screen_list):110 for screen in copy.deepcopy(self.screen_list):
111 if screen['number'] == self.desktop.screenCount():111 if screen['number'] == self.desktop.screenCount():
@@ -132,9 +132,11 @@
132 """132 """
133 screen_list = []133 screen_list = []
134 for screen in self.screen_list:134 for screen in self.screen_list:
135 screen_name = '%s %d' % (translate('OpenLP.ScreenList', 'Screen'), screen['number'] + 1)135 screen_name = '{name} {number:d}'.format(name=translate('OpenLP.ScreenList', 'Screen'),
136 number=screen['number'] + 1)
136 if screen['primary']:137 if screen['primary']:
137 screen_name = '%s (%s)' % (screen_name, translate('OpenLP.ScreenList', 'primary'))138 screen_name = '{name} ({primary})'.format(name=screen_name,
139 primary=translate('OpenLP.ScreenList', 'primary'))
138 screen_list.append(screen_name)140 screen_list.append(screen_name)
139 return screen_list141 return screen_list
140142
@@ -152,7 +154,7 @@
152 'size': PyQt5.QtCore.QRect(0, 0, 1024, 768)154 'size': PyQt5.QtCore.QRect(0, 0, 1024, 768)
153 }155 }
154 """156 """
155 log.info('Screen %d found with resolution %s' % (screen['number'], screen['size']))157 log.info('Screen {number:d} found with resolution {size}'.format(number=screen['number'], size=screen['size']))
156 if screen['primary']:158 if screen['primary']:
157 self.current = screen159 self.current = screen
158 self.override = copy.deepcopy(self.current)160 self.override = copy.deepcopy(self.current)
@@ -165,7 +167,7 @@
165167
166 :param number: The screen number (int).168 :param number: The screen number (int).
167 """169 """
168 log.info('remove_screen %d' % number)170 log.info('remove_screen {number:d}'.forma(number=number))
169 for screen in self.screen_list:171 for screen in self.screen_list:
170 if screen['number'] == number:172 if screen['number'] == number:
171 self.screen_list.remove(screen)173 self.screen_list.remove(screen)
@@ -189,7 +191,7 @@
189191
190 :param number: The screen number (int).192 :param number: The screen number (int).
191 """193 """
192 log.debug('set_current_display %s' % number)194 log.debug('set_current_display {number}'.format(number=number))
193 if number + 1 > self.display_count:195 if number + 1 > self.display_count:
194 self.current = self.screen_list[0]196 self.current = self.screen_list[0]
195 else:197 else:
196198
=== modified file 'openlp/core/lib/searchedit.py'
--- openlp/core/lib/searchedit.py 2015-12-31 22:46:06 +0000
+++ openlp/core/lib/searchedit.py 2016-05-17 13:27:53 +0000
@@ -62,9 +62,10 @@
62 right_padding = self.clear_button.width() + frame_width62 right_padding = self.clear_button.width() + frame_width
63 if hasattr(self, 'menu_button'):63 if hasattr(self, 'menu_button'):
64 left_padding = self.menu_button.width()64 left_padding = self.menu_button.width()
65 stylesheet = 'QLineEdit { padding-left: %spx; padding-right: %spx; } ' % (left_padding, right_padding)65 stylesheet = 'QLineEdit {{ padding-left:{left}px; padding-right: {right}px; }} '.format(left=left_padding,
66 right=right_padding)
66 else:67 else:
67 stylesheet = 'QLineEdit { padding-right: %spx; } ' % right_padding68 stylesheet = 'QLineEdit {{ padding-right: {right}px; }} '.format(right=right_padding)
68 self.setStyleSheet(stylesheet)69 self.setStyleSheet(stylesheet)
69 msz = self.minimumSizeHint()70 msz = self.minimumSizeHint()
70 self.setMinimumSize(max(msz.width(), self.clear_button.width() + (frame_width * 2) + 2),71 self.setMinimumSize(max(msz.width(), self.clear_button.width() + (frame_width * 2) + 2),
7172
=== modified file 'openlp/core/lib/serviceitem.py'
--- openlp/core/lib/serviceitem.py 2016-05-05 03:57:04 +0000
+++ openlp/core/lib/serviceitem.py 2016-05-17 13:27:53 +0000
@@ -247,7 +247,7 @@
247 self.renderer.set_item_theme(self.theme)247 self.renderer.set_item_theme(self.theme)
248 self.theme_data, self.main, self.footer = self.renderer.pre_render()248 self.theme_data, self.main, self.footer = self.renderer.pre_render()
249 if self.service_item_type == ServiceItemType.Text:249 if self.service_item_type == ServiceItemType.Text:
250 log.debug('Formatting slides: %s' % self.title)250 log.debug('Formatting slides: {title}'.format(title=self.title))
251 # Save rendered pages to this dict. In the case that a slide is used twice we can use the pages saved to251 # Save rendered pages to this dict. In the case that a slide is used twice we can use the pages saved to
252 # the dict instead of rendering them again.252 # the dict instead of rendering them again.
253 previous_pages = {}253 previous_pages = {}
@@ -270,7 +270,7 @@
270 elif self.service_item_type == ServiceItemType.Image or self.service_item_type == ServiceItemType.Command:270 elif self.service_item_type == ServiceItemType.Image or self.service_item_type == ServiceItemType.Command:
271 pass271 pass
272 else:272 else:
273 log.error('Invalid value renderer: %s' % self.service_item_type)273 log.error('Invalid value renderer: {item}'.format(item=self.service_item_type))
274 self.title = clean_tags(self.title)274 self.title = clean_tags(self.title)
275 # The footer should never be None, but to be compatible with a few275 # The footer should never be None, but to be compatible with a few
276 # nightly builds between 1.9.4 and 1.9.5, we have to correct this to276 # nightly builds between 1.9.4 and 1.9.5, we have to correct this to
@@ -325,7 +325,8 @@
325 self.service_item_type = ServiceItemType.Command325 self.service_item_type = ServiceItemType.Command
326 # If the item should have a display title but this frame doesn't have one, we make one up326 # If the item should have a display title but this frame doesn't have one, we make one up
327 if self.is_capable(ItemCapabilities.HasDisplayTitle) and not display_title:327 if self.is_capable(ItemCapabilities.HasDisplayTitle) and not display_title:
328 display_title = translate('OpenLP.ServiceItem', '[slide %d]') % (len(self._raw_frames) + 1)328 display_title = translate('OpenLP.ServiceItem',
329 '[slide {frame:d}]').format(frame=len(self._raw_frames) + 1)
329 # Update image path to match servicemanager location if file was loaded from service330 # Update image path to match servicemanager location if file was loaded from service
330 if image and not self.has_original_files and self.name == 'presentations':331 if image and not self.has_original_files and self.name == 'presentations':
331 file_location = os.path.join(path, file_name)332 file_location = os.path.join(path, file_name)
@@ -392,7 +393,7 @@
392 :param path: Defaults to *None*. This is the service manager path for things which have their files saved393 :param path: Defaults to *None*. This is the service manager path for things which have their files saved
393 with them or None when the saved service is lite and the original file paths need to be preserved.394 with them or None when the saved service is lite and the original file paths need to be preserved.
394 """395 """
395 log.debug('set_from_service called with path %s' % path)396 log.debug('set_from_service called with path {path}'.format(path=path))
396 header = service_item['serviceitem']['header']397 header = service_item['serviceitem']['header']
397 self.title = header['title']398 self.title = header['title']
398 self.name = header['name']399 self.name = header['name']
@@ -608,11 +609,13 @@
608 start = None609 start = None
609 end = None610 end = None
610 if self.start_time != 0:611 if self.start_time != 0:
611 start = translate('OpenLP.ServiceItem', '<strong>Start</strong>: %s') % \612 time = str(datetime.timedelta(seconds=self.start_time))
612 str(datetime.timedelta(seconds=self.start_time))613 start = translate('OpenLP.ServiceItem',
614 '<strong>Start</strong>: {start}').format(start=time)
613 if self.media_length != 0:615 if self.media_length != 0:
614 end = translate('OpenLP.ServiceItem', '<strong>Length</strong>: %s') % \616 length = str(datetime.timedelta(seconds=self.media_length // 1000))
615 str(datetime.timedelta(seconds=self.media_length // 1000))617 end = translate('OpenLP.ServiceItem', '<strong>Length</strong>: {length}').format(length=length)
618
616 if not start and not end:619 if not start and not end:
617 return ''620 return ''
618 elif start and not end:621 elif start and not end:
@@ -620,7 +623,7 @@
620 elif not start and end:623 elif not start and end:
621 return end624 return end
622 else:625 else:
623 return '%s <br>%s' % (start, end)626 return '{start} <br>{end}'.format(start=start, end=end)
624627
625 def update_theme(self, theme):628 def update_theme(self, theme):
626 """629 """
627630
=== modified file 'openlp/core/lib/theme.py'
--- openlp/core/lib/theme.py 2016-04-30 15:40:23 +0000
+++ openlp/core/lib/theme.py 2016-05-17 13:27:53 +0000
@@ -427,7 +427,7 @@
427 try:427 try:
428 theme_xml = objectify.fromstring(xml)428 theme_xml = objectify.fromstring(xml)
429 except etree.XMLSyntaxError:429 except etree.XMLSyntaxError:
430 log.exception('Invalid xml %s', xml)430 log.exception('Invalid xml {text}'.format(text=xml))
431 return431 return
432 xml_iter = theme_xml.getiterator()432 xml_iter = theme_xml.getiterator()
433 for element in xml_iter:433 for element in xml_iter:
@@ -513,6 +513,7 @@
513 theme_strings = []513 theme_strings = []
514 for key in dir(self):514 for key in dir(self):
515 if key[0:1] != '_':515 if key[0:1] != '_':
516 # TODO: Verify spacing format before converting to python3 string
516 theme_strings.append('%30s: %s' % (key, getattr(self, key)))517 theme_strings.append('%30s: %s' % (key, getattr(self, key)))
517 return '\n'.join(theme_strings)518 return '\n'.join(theme_strings)
518519
519520
=== modified file 'openlp/core/lib/ui.py'
--- openlp/core/lib/ui.py 2016-03-31 16:34:22 +0000
+++ openlp/core/lib/ui.py 2016-05-17 13:27:53 +0000
@@ -165,7 +165,7 @@
165 kwargs.setdefault('icon', ':/services/service_down.png')165 kwargs.setdefault('icon', ':/services/service_down.png')
166 kwargs.setdefault('tooltip', translate('OpenLP.Ui', 'Move selection down one position.'))166 kwargs.setdefault('tooltip', translate('OpenLP.Ui', 'Move selection down one position.'))
167 else:167 else:
168 log.warning('The role "%s" is not defined in create_push_button().', role)168 log.warning('The role "{role}" is not defined in create_push_button().'.format(role=role))
169 if kwargs.pop('btn_class', '') == 'toolbutton':169 if kwargs.pop('btn_class', '') == 'toolbutton':
170 button = QtWidgets.QToolButton(parent)170 button = QtWidgets.QToolButton(parent)
171 else:171 else:
@@ -183,7 +183,7 @@
183 button.clicked.connect(kwargs.pop('click'))183 button.clicked.connect(kwargs.pop('click'))
184 for key in list(kwargs.keys()):184 for key in list(kwargs.keys()):
185 if key not in ['text', 'icon', 'tooltip', 'click']:185 if key not in ['text', 'icon', 'tooltip', 'click']:
186 log.warning('Parameter %s was not consumed in create_button().', key)186 log.warning('Parameter {key} was not consumed in create_button().'.format(key=key))
187 return button187 return button
188188
189189
@@ -270,7 +270,7 @@
270 action.triggered.connect(kwargs.pop('triggers'))270 action.triggered.connect(kwargs.pop('triggers'))
271 for key in list(kwargs.keys()):271 for key in list(kwargs.keys()):
272 if key not in ['text', 'icon', 'tooltip', 'statustip', 'checked', 'can_shortcuts', 'category', 'triggers']:272 if key not in ['text', 'icon', 'tooltip', 'statustip', 'checked', 'can_shortcuts', 'category', 'triggers']:
273 log.warning('Parameter %s was not consumed in create_action().' % key)273 log.warning('Parameter {key} was not consumed in create_action().'.format(key=key))
274 return action274 return action
275275
276276
277277
=== modified file 'openlp/core/lib/webpagereader.py'
--- openlp/core/lib/webpagereader.py 2016-04-05 18:33:50 +0000
+++ openlp/core/lib/webpagereader.py 2016-05-17 13:27:53 +0000
@@ -133,37 +133,37 @@
133 time.sleep(0.1)133 time.sleep(0.1)
134 try:134 try:
135 page = urllib.request.urlopen(req, timeout=CONNECTION_TIMEOUT)135 page = urllib.request.urlopen(req, timeout=CONNECTION_TIMEOUT)
136 log.debug('Downloaded page {}'.format(page.geturl()))136 log.debug('Downloaded page {text}'.format(text=page.geturl()))
137 break137 break
138 except urllib.error.URLError as err:138 except urllib.error.URLError as err:
139 log.exception('URLError on {}'.format(url))139 log.exception('URLError on {text}'.format(text=url))
140 log.exception('URLError: {}'.format(err.reason))140 log.exception('URLError: {text}'.format(text=err.reason))
141 page = None141 page = None
142 if retries > CONNECTION_RETRIES:142 if retries > CONNECTION_RETRIES:
143 raise143 raise
144 except socket.timeout:144 except socket.timeout:
145 log.exception('Socket timeout: {}'.format(url))145 log.exception('Socket timeout: {text}'.format(text=url))
146 page = None146 page = None
147 if retries > CONNECTION_RETRIES:147 if retries > CONNECTION_RETRIES:
148 raise148 raise
149 except socket.gaierror:149 except socket.gaierror:
150 log.exception('Socket gaierror: {}'.format(url))150 log.exception('Socket gaierror: {text}'.format(text=url))
151 page = None151 page = None
152 if retries > CONNECTION_RETRIES:152 if retries > CONNECTION_RETRIES:
153 raise153 raise
154 except ConnectionRefusedError:154 except ConnectionRefusedError:
155 log.exception('ConnectionRefused: {}'.format(url))155 log.exception('ConnectionRefused: {text}'.format(text=url))
156 page = None156 page = None
157 if retries > CONNECTION_RETRIES:157 if retries > CONNECTION_RETRIES:
158 raise158 raise
159 break159 break
160 except ConnectionError:160 except ConnectionError:
161 log.exception('Connection error: {}'.format(url))161 log.exception('Connection error: {text}'.format(text=url))
162 page = None162 page = None
163 if retries > CONNECTION_RETRIES:163 if retries > CONNECTION_RETRIES:
164 raise164 raise
165 except HTTPException:165 except HTTPException:
166 log.exception('HTTPException error: {}'.format(url))166 log.exception('HTTPException error: {text}'.format(text=url))
167 page = None167 page = None
168 if retries > CONNECTION_RETRIES:168 if retries > CONNECTION_RETRIES:
169 raise169 raise
@@ -173,7 +173,7 @@
173 if update_openlp:173 if update_openlp:
174 Registry().get('application').process_events()174 Registry().get('application').process_events()
175 if not page:175 if not page:
176 log.exception('{} could not be downloaded'.format(url))176 log.exception('{text} could not be downloaded'.format(text=url))
177 return None177 return None
178 log.debug(page)178 log.debug(page)
179 return page179 return page
180180
=== modified file 'tests/functional/openlp_core_lib/test_projector_pjlink1.py'
--- tests/functional/openlp_core_lib/test_projector_pjlink1.py 2016-04-24 11:22:04 +0000
+++ tests/functional/openlp_core_lib/test_projector_pjlink1.py 2016-05-17 13:27:53 +0000
@@ -112,7 +112,7 @@
112 @patch.object(pjlink_test, 'projectorReceivedData')112 @patch.object(pjlink_test, 'projectorReceivedData')
113 def projector_process_lamp_test(self, mock_projectorReceivedData):113 def projector_process_lamp_test(self, mock_projectorReceivedData):
114 """114 """
115 Test setting lamp on/off and hours115 Test status lamp on/off and hours
116 """116 """
117 # GIVEN: Test object117 # GIVEN: Test object
118 pjlink = pjlink_test118 pjlink = pjlink_test
@@ -129,7 +129,7 @@
129 @patch.object(pjlink_test, 'projectorReceivedData')129 @patch.object(pjlink_test, 'projectorReceivedData')
130 def projector_process_multiple_lamp_test(self, mock_projectorReceivedData):130 def projector_process_multiple_lamp_test(self, mock_projectorReceivedData):
131 """131 """
132 Test setting multiple lamp on/off and hours132 Test status multiple lamp on/off and hours
133 """133 """
134 # GIVEN: Test object134 # GIVEN: Test object
135 pjlink = pjlink_test135 pjlink = pjlink_test
@@ -156,7 +156,7 @@
156 @patch.object(pjlink_test, 'projectorReceivedData')156 @patch.object(pjlink_test, 'projectorReceivedData')
157 def projector_process_power_on_test(self, mock_projectorReceivedData):157 def projector_process_power_on_test(self, mock_projectorReceivedData):
158 """158 """
159 Test setting power to ON159 Test status power to ON
160 """160 """
161 # GIVEN: Test object and preset161 # GIVEN: Test object and preset
162 pjlink = pjlink_test162 pjlink = pjlink_test
@@ -171,7 +171,7 @@
171 @patch.object(pjlink_test, 'projectorReceivedData')171 @patch.object(pjlink_test, 'projectorReceivedData')
172 def projector_process_power_off_test(self, mock_projectorReceivedData):172 def projector_process_power_off_test(self, mock_projectorReceivedData):
173 """173 """
174 Test setting power to STANDBY174 Test status power to STANDBY
175 """175 """
176 # GIVEN: Test object and preset176 # GIVEN: Test object and preset
177 pjlink = pjlink_test177 pjlink = pjlink_test
@@ -182,3 +182,71 @@
182182
183 # THEN: Power should be set to STANDBY183 # THEN: Power should be set to STANDBY
184 self.assertEquals(pjlink.power, S_STANDBY, 'Power should have been set to STANDBY')184 self.assertEquals(pjlink.power, S_STANDBY, 'Power should have been set to STANDBY')
185
186 @patch.object(pjlink_test, 'projectorUpdateIcons')
187 def projector_process_avmt_closed_unmuted_test(self, mock_projectorReceivedData):
188 """
189 Test avmt status shutter closed and audio muted
190 """
191 # GIVEN: Test object
192 pjlink = pjlink_test
193 pjlink.shutter = False
194 pjlink.mute = True
195
196 # WHEN: Called with setting shutter closed and mute off
197 pjlink.process_avmt('11')
198
199 # THEN: Shutter should be True and mute should be False
200 self.assertTrue(pjlink.shutter, 'Shutter should have been set to closed')
201 self.assertFalse(pjlink.mute, 'Audio should be off')
202
203 @patch.object(pjlink_test, 'projectorUpdateIcons')
204 def projector_process_avmt_open_muted_test(self, mock_projectorReceivedData):
205 """
206 Test avmt status shutter open and mute on
207 """
208 # GIVEN: Test object
209 pjlink = pjlink_test
210 pjlink.shutter = True
211 pjlink.mute = False
212
213 # WHEN: Called with setting shutter closed and mute on
214 pjlink.process_avmt('21')
215
216 # THEN: Shutter should be closed and mute should be True
217 self.assertFalse(pjlink.shutter, 'Shutter should have been set to closed')
218 self.assertTrue(pjlink.mute, 'Audio should be off')
219
220 @patch.object(pjlink_test, 'projectorUpdateIcons')
221 def projector_process_avmt_open_unmuted_test(self, mock_projectorReceivedData):
222 """
223 Test avmt status shutter open and mute off off
224 """
225 # GIVEN: Test object
226 pjlink = pjlink_test
227 pjlink.shutter = True
228 pjlink.mute = True
229
230 # WHEN: Called with setting shutter to closed and mute on
231 pjlink.process_avmt('30')
232
233 # THEN: Shutter should be closed and mute should be True
234 self.assertFalse(pjlink.shutter, 'Shutter should have been set to open')
235 self.assertFalse(pjlink.mute, 'Audio should be on')
236
237 @patch.object(pjlink_test, 'projectorUpdateIcons')
238 def projector_process_avmt_closed_muted_test(self, mock_projectorReceivedData):
239 """
240 Test avmt status shutter closed and mute off
241 """
242 # GIVEN: Test object
243 pjlink = pjlink_test
244 pjlink.shutter = False
245 pjlink.mute = False
246
247 # WHEN: Called with setting shutter to closed and mute on
248 pjlink.process_avmt('31')
249
250 # THEN: Shutter should be closed and mute should be True
251 self.assertTrue(pjlink.shutter, 'Shutter should have been set to closed')
252 self.assertTrue(pjlink.mute, 'Audio should be on')