Convert strings in plugins part 2

- Convert strings in custom
- Convert strings in images
- Convert strings in media
- Convert strings in presentations
- Update projector-pjlink test

--------------------------------
lp:~alisonken1/openlp/strings-plugins2 (revision 2667)
[SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/1571/
[SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/1482/
[SUCCESS] https://ci.openlp.io/job/Branch-03-Interface-Tests/1420/
[SUCCESS] https://ci.openlp.io/jo...

bzr-revno: 2668
This commit is contained in:
Ken Roberts 2016-05-24 17:18:25 +01:00 committed by Tim Bentley
commit 473772c505
16 changed files with 141 additions and 91 deletions

View File

@ -128,7 +128,7 @@ class CustomXMLParser(object):
try: try:
self.custom_xml = objectify.fromstring(xml) self.custom_xml = objectify.fromstring(xml)
except etree.XMLSyntaxError: except etree.XMLSyntaxError:
log.exception('Invalid xml %s', xml) log.exception('Invalid xml {xml}'.format(xml=xml))
def get_verses(self): def get_verses(self):
""" """

View File

@ -94,7 +94,7 @@ class CustomMediaItem(MediaManagerItem):
""" """
""" """
self.search_text_label.setText('%s:' % UiStrings().Search) self.search_text_label.setText('{text}:'.format(text=UiStrings().Search))
self.search_text_button.setText(UiStrings().Search) self.search_text_button.setText(UiStrings().Search)
def initialise(self): def initialise(self):
@ -105,7 +105,8 @@ class CustomMediaItem(MediaManagerItem):
[(CustomSearch.Titles, ':/songs/song_search_title.png', translate('SongsPlugin.MediaItem', 'Titles'), [(CustomSearch.Titles, ':/songs/song_search_title.png', translate('SongsPlugin.MediaItem', 'Titles'),
translate('SongsPlugin.MediaItem', 'Search Titles...')), translate('SongsPlugin.MediaItem', 'Search Titles...')),
(CustomSearch.Themes, ':/slides/slide_theme.png', UiStrings().Themes, UiStrings().SearchThemes)]) (CustomSearch.Themes, ':/slides/slide_theme.png', UiStrings().Themes, UiStrings().SearchThemes)])
self.search_text_edit.set_current_search_type(Settings().value('%s/last search type' % self.settings_section)) text = '{section}/last search type'.format(section=self.settings_section)
self.search_text_edit.set_current_search_type(Settings().value(text))
self.load_list(self.plugin.db_manager.get_all_objects(CustomSlide, order_by_ref=CustomSlide.title)) self.load_list(self.plugin.db_manager.get_all_objects(CustomSlide, order_by_ref=CustomSlide.title))
self.config_update() self.config_update()
@ -190,7 +191,8 @@ class CustomMediaItem(MediaManagerItem):
if QtWidgets.QMessageBox.question( if QtWidgets.QMessageBox.question(
self, UiStrings().ConfirmDelete, self, UiStrings().ConfirmDelete,
translate('CustomPlugin.MediaItem', translate('CustomPlugin.MediaItem',
'Are you sure you want to delete the "%d" selected custom slide(s)?') % len(items), 'Are you sure you want to delete the "{items:d}" '
'selected custom slide(s)?').format(items=len(items)),
QtWidgets.QMessageBox.StandardButtons( QtWidgets.QMessageBox.StandardButtons(
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No), QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No),
QtWidgets.QMessageBox.Yes) == QtWidgets.QMessageBox.No: QtWidgets.QMessageBox.Yes) == QtWidgets.QMessageBox.No:
@ -249,10 +251,11 @@ class CustomMediaItem(MediaManagerItem):
Search the plugin database Search the plugin database
""" """
# Save the current search type to the configuration. # Save the current search type to the configuration.
Settings().setValue('%s/last search type' % self.settings_section, self.search_text_edit.current_search_type()) Settings().setValue('{section}/last search type'.format(section=self.settings_section),
self.search_text_edit.current_search_type())
# Reload the list considering the new search type. # Reload the list considering the new search type.
search_type = self.search_text_edit.current_search_type() search_type = self.search_text_edit.current_search_type()
search_keywords = '%' + self.whitespace.sub(' ', self.search_text_edit.displayText()) + '%' search_keywords = '%{search}%'.format(search=self.whitespace.sub(' ', self.search_text_edit.displayText()))
if search_type == CustomSearch.Titles: if search_type == CustomSearch.Titles:
log.debug('Titles Search') log.debug('Titles Search')
search_results = self.plugin.db_manager.get_all_objects(CustomSlide, search_results = self.plugin.db_manager.get_all_objects(CustomSlide,
@ -347,7 +350,7 @@ class CustomMediaItem(MediaManagerItem):
:param string: The search string :param string: The search string
:param show_error: The error string to be show. :param show_error: The error string to be show.
""" """
search = '%' + string.lower() + '%' search = '%{search}%'.forma(search=string.lower())
search_results = self.plugin.db_manager.get_all_objects(CustomSlide, search_results = self.plugin.db_manager.get_all_objects(CustomSlide,
or_(func.lower(CustomSlide.title).like(search), or_(func.lower(CustomSlide.title).like(search),
func.lower(CustomSlide.text).like(search)), func.lower(CustomSlide.text).like(search)),

View File

@ -74,7 +74,7 @@ class ImageMediaItem(MediaManagerItem):
def retranslateUi(self): def retranslateUi(self):
self.on_new_prompt = translate('ImagePlugin.MediaItem', 'Select Image(s)') self.on_new_prompt = translate('ImagePlugin.MediaItem', 'Select Image(s)')
file_formats = get_images_filter() file_formats = get_images_filter()
self.on_new_file_masks = '%s;;%s (*)' % (file_formats, UiStrings().AllFiles) self.on_new_file_masks = '{formats};;{files} (*)'.format(formats=file_formats, files=UiStrings().AllFiles)
self.add_group_action.setText(UiStrings().AddGroup) self.add_group_action.setText(UiStrings().AddGroup)
self.add_group_action.setToolTip(UiStrings().AddGroup) self.add_group_action.setToolTip(UiStrings().AddGroup)
self.replace_action.setText(UiStrings().ReplaceBG) self.replace_action.setText(UiStrings().ReplaceBG)
@ -113,7 +113,7 @@ class ImageMediaItem(MediaManagerItem):
self.list_view = TreeWidgetWithDnD(self, self.plugin.name) self.list_view = TreeWidgetWithDnD(self, self.plugin.name)
self.list_view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) self.list_view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
self.list_view.setAlternatingRowColors(True) self.list_view.setAlternatingRowColors(True)
self.list_view.setObjectName('%sTreeView' % self.plugin.name) self.list_view.setObjectName('{name}TreeView'.format(name=self.plugin.name))
# Add to pageLayout # Add to pageLayout
self.page_layout.addWidget(self.list_view) self.page_layout.addWidget(self.list_view)
# define and add the context menu # define and add the context menu
@ -127,21 +127,21 @@ class ImageMediaItem(MediaManagerItem):
create_widget_action(self.list_view, separator=True) create_widget_action(self.list_view, separator=True)
create_widget_action( create_widget_action(
self.list_view, self.list_view,
'listView%s%sItem' % (self.plugin.name.title(), StringContent.Preview.title()), 'listView{name}{preview}Item'.format(name=self.plugin.name.title(), preview=StringContent.Preview.title()),
text=self.plugin.get_string(StringContent.Preview)['title'], text=self.plugin.get_string(StringContent.Preview)['title'],
icon=':/general/general_preview.png', icon=':/general/general_preview.png',
can_shortcuts=True, can_shortcuts=True,
triggers=self.on_preview_click) triggers=self.on_preview_click)
create_widget_action( create_widget_action(
self.list_view, self.list_view,
'listView%s%sItem' % (self.plugin.name.title(), StringContent.Live.title()), 'listView{name}{live}Item'.format(name=self.plugin.name.title(), live=StringContent.Live.title()),
text=self.plugin.get_string(StringContent.Live)['title'], text=self.plugin.get_string(StringContent.Live)['title'],
icon=':/general/general_live.png', icon=':/general/general_live.png',
can_shortcuts=True, can_shortcuts=True,
triggers=self.on_live_click) triggers=self.on_live_click)
create_widget_action( create_widget_action(
self.list_view, self.list_view,
'listView%s%sItem' % (self.plugin.name.title(), StringContent.Service.title()), 'listView{name}{service}Item'.format(name=self.plugin.name.title(), service=StringContent.Service.title()),
can_shortcuts=True, can_shortcuts=True,
text=self.plugin.get_string(StringContent.Service)['title'], text=self.plugin.get_string(StringContent.Service)['title'],
icon=':/general/general_add.png', icon=':/general/general_add.png',
@ -157,7 +157,7 @@ class ImageMediaItem(MediaManagerItem):
if self.has_delete_icon: if self.has_delete_icon:
create_widget_action( create_widget_action(
self.list_view, self.list_view,
'listView%s%sItem' % (self.plugin.name.title(), StringContent.Delete.title()), 'listView{name}{delete}Item'.format(name=self.plugin.name.title(), delete=StringContent.Delete.title()),
text=self.plugin.get_string(StringContent.Delete)['title'], text=self.plugin.get_string(StringContent.Delete)['title'],
icon=':/general/general_delete.png', icon=':/general/general_delete.png',
can_shortcuts=True, triggers=self.on_delete_click) can_shortcuts=True, triggers=self.on_delete_click)
@ -245,8 +245,8 @@ class ImageMediaItem(MediaManagerItem):
self.list_view.parent(), self.list_view.parent(),
translate('ImagePlugin.MediaItem', 'Remove group'), translate('ImagePlugin.MediaItem', 'Remove group'),
translate('ImagePlugin.MediaItem', translate('ImagePlugin.MediaItem',
'Are you sure you want to remove "%s" and everything in it?') % 'Are you sure you want to remove "{name}" and everything in it?'
item_data.group_name, ).format(name=item_data.group_name),
QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes |
QtWidgets.QMessageBox.No) QtWidgets.QMessageBox.No)
) == QtWidgets.QMessageBox.Yes: ) == QtWidgets.QMessageBox.Yes:
@ -355,7 +355,7 @@ class ImageMediaItem(MediaManagerItem):
# characters. # characters.
images.sort(key=lambda image_object: get_locale_key(os.path.split(str(image_object.filename))[1])) images.sort(key=lambda image_object: get_locale_key(os.path.split(str(image_object.filename))[1]))
for image_file in images: for image_file in images:
log.debug('Loading image: %s', image_file.filename) log.debug('Loading image: {name}'.format(name=image_file.filename))
filename = os.path.split(image_file.filename)[1] filename = os.path.split(image_file.filename)[1]
thumb = self.generate_thumbnail_path(image_file) thumb = self.generate_thumbnail_path(image_file)
if not os.path.exists(image_file.filename): if not os.path.exists(image_file.filename):
@ -481,7 +481,7 @@ class ImageMediaItem(MediaManagerItem):
for filename in images_list: for filename in images_list:
if not isinstance(filename, str): if not isinstance(filename, str):
continue continue
log.debug('Adding new image: %s', filename) log.debug('Adding new image: {name}'.format(name=filename))
image_file = ImageFilenames() image_file = ImageFilenames()
image_file.group_id = group_id image_file.group_id = group_id
image_file.filename = str(filename) image_file.filename = str(filename)
@ -589,14 +589,15 @@ class ImageMediaItem(MediaManagerItem):
if not remote: if not remote:
critical_error_message_box( critical_error_message_box(
translate('ImagePlugin.MediaItem', 'Missing Image(s)'), translate('ImagePlugin.MediaItem', 'Missing Image(s)'),
translate('ImagePlugin.MediaItem', 'The following image(s) no longer exist: %s') translate('ImagePlugin.MediaItem', 'The following image(s) no longer exist: {names}'
% '\n'.join(missing_items_file_names)) ).format(names='\n'.join(missing_items_file_names)))
return False return False
# We have missing as well as existing images. We ask what to do. # We have missing as well as existing images. We ask what to do.
elif missing_items_file_names and QtWidgets.QMessageBox.question( elif missing_items_file_names and QtWidgets.QMessageBox.question(
self, translate('ImagePlugin.MediaItem', 'Missing Image(s)'), self, translate('ImagePlugin.MediaItem', 'Missing Image(s)'),
translate('ImagePlugin.MediaItem', 'The following image(s) no longer exist: %s\n' translate('ImagePlugin.MediaItem', 'The following image(s) no longer exist: {names}\n'
'Do you want to add the other images anyway?') % '\n'.join(missing_items_file_names), 'Do you want to add the other images anyway?'
).format(names='\n'.join(missing_items_file_names)),
QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Yes)) == \ QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Yes)) == \
QtWidgets.QMessageBox.No: QtWidgets.QMessageBox.No:
return False return False
@ -688,7 +689,7 @@ class ImageMediaItem(MediaManagerItem):
critical_error_message_box( critical_error_message_box(
UiStrings().LiveBGError, UiStrings().LiveBGError,
translate('ImagePlugin.MediaItem', 'There was a problem replacing your background, ' translate('ImagePlugin.MediaItem', 'There was a problem replacing your background, '
'the image file "%s" no longer exists.') % filename) 'the image file "{name}" no longer exists.').format(name=filename))
def search(self, string, show_error=True): def search(self, string, show_error=True):
""" """

View File

@ -46,7 +46,7 @@ class MediaClipSelectorForm(QtWidgets.QDialog, Ui_MediaClipSelector, RegistryPro
""" """
Class to manage the clip selection Class to manage the clip selection
""" """
log.info('%s MediaClipSelectorForm loaded', __name__) log.info('{name} MediaClipSelectorForm loaded'.format(name=__name__))
def __init__(self, media_item, parent, manager): def __init__(self, media_item, parent, manager):
""" """
@ -265,7 +265,8 @@ class MediaClipSelectorForm(QtWidgets.QDialog, Ui_MediaClipSelector, RegistryPro
# Enable audio track combobox if anything is in it # Enable audio track combobox if anything is in it
if len(titles) > 0: if len(titles) > 0:
self.titles_combo_box.setDisabled(False) self.titles_combo_box.setDisabled(False)
log.debug('load_disc_button end - vlc_media_player state: %s' % self.vlc_media_player.get_state()) log.debug('load_disc_button end - '
'vlc_media_player state: {state}'.format(state=self.vlc_media_player.get_state()))
@QtCore.pyqtSlot(bool) @QtCore.pyqtSlot(bool)
def on_play_button_clicked(self, clicked): def on_play_button_clicked(self, clicked):
@ -374,7 +375,7 @@ class MediaClipSelectorForm(QtWidgets.QDialog, Ui_MediaClipSelector, RegistryPro
:param index: The index of the newly chosen title track. :param index: The index of the newly chosen title track.
""" """
log.debug('in on_titles_combo_box_changed, index: %d', index) log.debug('in on_titles_combo_box_changed, index: {index:d}'.format(index=index))
vlc = get_vlc() vlc = get_vlc()
if not self.vlc_media_player: if not self.vlc_media_player:
log.error('vlc_media_player was None') log.error('vlc_media_player was None')
@ -407,7 +408,7 @@ class MediaClipSelectorForm(QtWidgets.QDialog, Ui_MediaClipSelector, RegistryPro
self.vlc_media_player.audio_set_mute(True) self.vlc_media_player.audio_set_mute(True)
# Get audio tracks # Get audio tracks
audio_tracks = self.vlc_media_player.audio_get_track_description() audio_tracks = self.vlc_media_player.audio_get_track_description()
log.debug('number of audio tracks: %d' % len(audio_tracks)) log.debug('number of audio tracks: {tracks:d}'.format(tracks=len(audio_tracks)))
# Clear the audio track combobox, insert new tracks # Clear the audio track combobox, insert new tracks
self.audio_tracks_combobox.clear() self.audio_tracks_combobox.clear()
for audio_track in audio_tracks: for audio_track in audio_tracks:
@ -433,14 +434,14 @@ class MediaClipSelectorForm(QtWidgets.QDialog, Ui_MediaClipSelector, RegistryPro
self.toggle_disable_player(False) self.toggle_disable_player(False)
# Set media length info # Set media length info
self.playback_length = self.vlc_media_player.get_length() self.playback_length = self.vlc_media_player.get_length()
log.debug('playback_length: %d ms' % self.playback_length) log.debug('playback_length: {length:d} ms'.format(length=self.playback_length))
# if length is 0, wait a bit, maybe vlc will change its mind... # if length is 0, wait a bit, maybe vlc will change its mind...
loop_count = 0 loop_count = 0
while self.playback_length == 0 and loop_count < 20: while self.playback_length == 0 and loop_count < 20:
sleep(0.1) sleep(0.1)
self.playback_length = self.vlc_media_player.get_length() self.playback_length = self.vlc_media_player.get_length()
loop_count += 1 loop_count += 1
log.debug('in loop, playback_length: %d ms' % self.playback_length) log.debug('in loop, playback_length: {length:d} ms'.format(length=self.playback_length))
self.position_slider.setMaximum(self.playback_length) self.position_slider.setMaximum(self.playback_length)
# setup start and end time # setup start and end time
rounded_vlc_ms_length = int(round(self.playback_length / 100.0) * 100.0) rounded_vlc_ms_length = int(round(self.playback_length / 100.0) * 100.0)
@ -455,7 +456,8 @@ class MediaClipSelectorForm(QtWidgets.QDialog, Ui_MediaClipSelector, RegistryPro
sleep(0.1) sleep(0.1)
self.vlc_media_player.set_pause(1) self.vlc_media_player.set_pause(1)
loop_count += 1 loop_count += 1
log.debug('titles_combo_box end - vlc_media_player state: %s' % self.vlc_media_player.get_state()) log.debug('titles_combo_box end - '
'vlc_media_player state: {state}'.format(state=self.vlc_media_player.get_state()))
self.application.set_normal_cursor() self.application.set_normal_cursor()
@QtCore.pyqtSlot(int) @QtCore.pyqtSlot(int)
@ -468,7 +470,8 @@ class MediaClipSelectorForm(QtWidgets.QDialog, Ui_MediaClipSelector, RegistryPro
if not self.vlc_media_player: if not self.vlc_media_player:
return return
audio_track = self.audio_tracks_combobox.itemData(index) audio_track = self.audio_tracks_combobox.itemData(index)
log.debug('in on_audio_tracks_combobox_currentIndexChanged, index: %d audio_track: %s' % (index, audio_track)) log.debug('in on_audio_tracks_combobox_currentIndexChanged, '
'index: {index:d} audio_track: {tracks}'.format(index=index, tracks=audio_track))
if audio_track and int(audio_track) > 0: if audio_track and int(audio_track) > 0:
self.vlc_media_player.audio_set_track(int(audio_track)) self.vlc_media_player.audio_set_track(int(audio_track))
@ -566,7 +569,9 @@ class MediaClipSelectorForm(QtWidgets.QDialog, Ui_MediaClipSelector, RegistryPro
translate('MediaPlugin.MediaClipSelectorForm', translate('MediaPlugin.MediaClipSelectorForm',
'The CD was not loaded correctly, please re-load and try again.')) 'The CD was not loaded correctly, please re-load and try again.'))
return return
optical = 'optical:%d:-1:-1:%d:%d:' % (title, start_time_ms, end_time_ms) optical = 'optical:{title:d}:-1:-1:{start:d}:{end:d}:'.format(title=title,
start=start_time_ms,
end=end_time_ms)
else: else:
audio_track = self.audio_tracks_combobox.itemData(self.audio_tracks_combobox.currentIndex()) audio_track = self.audio_tracks_combobox.itemData(self.audio_tracks_combobox.currentIndex())
subtitle_track = self.subtitle_tracks_combobox.itemData(self.subtitle_tracks_combobox.currentIndex()) subtitle_track = self.subtitle_tracks_combobox.itemData(self.subtitle_tracks_combobox.currentIndex())
@ -577,7 +582,11 @@ class MediaClipSelectorForm(QtWidgets.QDialog, Ui_MediaClipSelector, RegistryPro
translate('MediaPlugin.MediaClipSelectorForm', translate('MediaPlugin.MediaClipSelectorForm',
'The DVD was not loaded correctly, please re-load and try again.')) 'The DVD was not loaded correctly, please re-load and try again.'))
return return
optical = 'optical:%d:%d:%d:%d:%d:' % (title, audio_track, subtitle_track, start_time_ms, end_time_ms) optical = 'optical:{title:d}:{audio:d}:{sub:d}:{start:d}:{end:d}:'.format(title=title,
audio=audio_track,
sub=subtitle_track,
start=start_time_ms,
end=end_time_ms)
# Ask for an alternative name for the mediaclip # Ask for an alternative name for the mediaclip
while True: while True:
new_optical_name, ok = QtWidgets.QInputDialog.getText(self, translate('MediaPlugin.MediaClipSelectorForm', new_optical_name, ok = QtWidgets.QInputDialog.getText(self, translate('MediaPlugin.MediaClipSelectorForm',
@ -634,10 +643,10 @@ class MediaClipSelectorForm(QtWidgets.QDialog, Ui_MediaClipSelector, RegistryPro
# use win api to find optical drives # use win api to find optical drives
fso = Dispatch('scripting.filesystemobject') fso = Dispatch('scripting.filesystemobject')
for drive in fso.Drives: for drive in fso.Drives:
log.debug('Drive %s has type %d' % (drive.DriveLetter, drive.DriveType)) log.debug('Drive {drive} has type {types:d}'.format(drive=drive.DriveLetter, types=drive.DriveType))
# if type is 4, it is a cd-rom drive # if type is 4, it is a cd-rom drive
if drive.DriveType == 4: if drive.DriveType == 4:
self.media_path_combobox.addItem('%s:\\' % drive.DriveLetter) self.media_path_combobox.addItem('{drive}:\\'.format(drive=drive.DriveLetter))
elif is_linux(): elif is_linux():
# Get disc devices from dbus and find the ones that are optical # Get disc devices from dbus and find the ones that are optical
bus = dbus.SystemBus() bus = dbus.SystemBus()

View File

@ -51,7 +51,7 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
""" """
media_go_live = QtCore.pyqtSignal(list) media_go_live = QtCore.pyqtSignal(list)
media_add_to_service = QtCore.pyqtSignal(list) media_add_to_service = QtCore.pyqtSignal(list)
log.info('%s MediaMediaItem loaded', __name__) log.info('{name} MediaMediaItem loaded'.format(name=__name__))
def __init__(self, parent, plugin): def __init__(self, parent, plugin):
self.setup() self.setup()
@ -232,7 +232,7 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
critical_error_message_box(UiStrings().LiveBGError, critical_error_message_box(UiStrings().LiveBGError,
translate('MediaPlugin.MediaItem', translate('MediaPlugin.MediaItem',
'There was a problem replacing your background, ' 'There was a problem replacing your background, '
'the media file "%s" no longer exists.') % filename) 'the media file "{name}" no longer exists.').format(name=filename))
def generate_slide_data(self, service_item, item=None, xml_version=False, remote=False, def generate_slide_data(self, service_item, item=None, xml_version=False, remote=False,
context=ServiceItemContext.Service): context=ServiceItemContext.Service):
@ -258,7 +258,8 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
# Optical disc is no longer present # Optical disc is no longer present
critical_error_message_box( critical_error_message_box(
translate('MediaPlugin.MediaItem', 'Missing Media File'), translate('MediaPlugin.MediaItem', 'Missing Media File'),
translate('MediaPlugin.MediaItem', 'The optical disc %s is no longer available.') % name) translate('MediaPlugin.MediaItem',
'The optical disc {name} is no longer available.').format(name=name))
return False return False
service_item.processor = self.display_type_combo_box.currentText() service_item.processor = self.display_type_combo_box.currentText()
service_item.add_from_command(filename, name, CLAPPERBOARD) service_item.add_from_command(filename, name, CLAPPERBOARD)
@ -275,7 +276,7 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
# File is no longer present # File is no longer present
critical_error_message_box( critical_error_message_box(
translate('MediaPlugin.MediaItem', 'Missing Media File'), translate('MediaPlugin.MediaItem', 'Missing Media File'),
translate('MediaPlugin.MediaItem', 'The file %s no longer exists.') % filename) translate('MediaPlugin.MediaItem', 'The file {name} no longer exists.').format(name=filename))
return False return False
(path, name) = os.path.split(filename) (path, name) = os.path.split(filename)
service_item.title = name service_item.title = name
@ -308,9 +309,11 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
Rebuild the tab in the media manager when changes are made in the settings. Rebuild the tab in the media manager when changes are made in the settings.
""" """
self.populate_display_types() self.populate_display_types()
self.on_new_file_masks = translate('MediaPlugin.MediaItem', 'Videos (%s);;Audio (%s);;%s (*)') % ( self.on_new_file_masks = translate('MediaPlugin.MediaItem',
' '.join(self.media_controller.video_extensions_list), 'Videos ({video});;Audio ({audio});;{files} '
' '.join(self.media_controller.audio_extensions_list), UiStrings().AllFiles) '(*)').format(video=' '.join(self.media_controller.video_extensions_list),
audio=' '.join(self.media_controller.audio_extensions_list),
files=UiStrings().AllFiles)
def populate_display_types(self): def populate_display_types(self):
""" """
@ -365,7 +368,9 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
item_name = QtWidgets.QListWidgetItem(clip_name) item_name = QtWidgets.QListWidgetItem(clip_name)
item_name.setIcon(self.optical_icon) item_name.setIcon(self.optical_icon)
item_name.setData(QtCore.Qt.UserRole, track) item_name.setData(QtCore.Qt.UserRole, track)
item_name.setToolTip('%s@%s-%s' % (file_name, format_milliseconds(start), format_milliseconds(end))) item_name.setToolTip('{name}@{start}-{end}'.format(name=file_name,
start=format_milliseconds(start),
end=format_milliseconds(end)))
elif not os.path.exists(track): elif not os.path.exists(track):
# File doesn't exist, mark as error. # File doesn't exist, mark as error.
file_name = os.path.split(str(track))[1] file_name = os.path.split(str(track))[1]
@ -377,7 +382,8 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
# Normal media file handling. # Normal media file handling.
file_name = os.path.split(str(track))[1] file_name = os.path.split(str(track))[1]
item_name = QtWidgets.QListWidgetItem(file_name) item_name = QtWidgets.QListWidgetItem(file_name)
if '*.%s' % (file_name.split('.')[-1].lower()) in self.media_controller.audio_extensions_list: search = file_name.split('.')[-1].lower()
if '*.{text}'.format(text=search) in self.media_controller.audio_extensions_list:
item_name.setIcon(self.audio_icon) item_name.setIcon(self.audio_icon)
else: else:
item_name.setIcon(self.video_icon) item_name.setIcon(self.video_icon)

View File

@ -49,7 +49,7 @@ class MediaPlugin(Plugin):
""" """
The media plugin adds the ability to playback audio and video content. The media plugin adds the ability to playback audio and video content.
""" """
log.info('%s MediaPlugin loaded', __name__) log.info('{name} MediaPlugin loaded'.format(name=__name__))
def __init__(self): def __init__(self):
super(MediaPlugin, self).__init__('media', __default_settings__, MediaMediaItem) super(MediaPlugin, self).__init__('media', __default_settings__, MediaMediaItem)

View File

@ -236,7 +236,7 @@ class ImpressDocument(PresentationDocument):
try: try:
self.document = desktop.loadComponentFromURL(url, '_blank', 0, properties) self.document = desktop.loadComponentFromURL(url, '_blank', 0, properties)
except: except:
log.warning('Failed to load presentation %s' % url) log.warning('Failed to load presentation {url}'.format(url=url))
return False return False
self.presentation = self.document.getPresentation() self.presentation = self.document.getPresentation()
self.presentation.Display = ScreenList().current['number'] + 1 self.presentation.Display = ScreenList().current['number'] + 1
@ -269,16 +269,16 @@ class ImpressDocument(PresentationDocument):
for index in range(pages.getCount()): for index in range(pages.getCount()):
page = pages.getByIndex(index) page = pages.getByIndex(index)
doc.getCurrentController().setCurrentPage(page) doc.getCurrentController().setCurrentPage(page)
url_path = '%s/%s.png' % (thumb_dir_url, str(index + 1)) url_path = '{path}/{name}.png'.format(path=thumb_dir_url, name=str(index + 1))
path = os.path.join(self.get_temp_folder(), str(index + 1) + '.png') path = os.path.join(self.get_temp_folder(), str(index + 1) + '.png')
try: try:
doc.storeToURL(url_path, properties) doc.storeToURL(url_path, properties)
self.convert_thumbnail(path, index + 1) self.convert_thumbnail(path, index + 1)
delete_file(path) delete_file(path)
except ErrorCodeIOException as exception: except ErrorCodeIOException as exception:
log.exception('ERROR! ErrorCodeIOException %d' % exception.ErrCode) log.exception('ERROR! ErrorCodeIOException {error:d}'.format(error=exception.ErrCode))
except: except:
log.exception('%s - Unable to store openoffice preview' % path) log.exception('{path} - Unable to store openoffice preview'.format(path=path))
def create_property(self, name, value): def create_property(self, name, value):
""" """

View File

@ -88,9 +88,10 @@ class PresentationMediaItem(MediaManagerItem):
file_types = self.controllers[controller].supports + self.controllers[controller].also_supports file_types = self.controllers[controller].supports + self.controllers[controller].also_supports
for file_type in file_types: for file_type in file_types:
if file_type not in file_type_string: if file_type not in file_type_string:
file_type_string += '*.%s ' % file_type file_type_string += '*.{text} '.format(text=file_type)
self.service_manager.supported_suffixes(file_type) self.service_manager.supported_suffixes(file_type)
self.on_new_file_masks = translate('PresentationPlugin.MediaItem', 'Presentations (%s)') % file_type_string self.on_new_file_masks = translate('PresentationPlugin.MediaItem',
'Presentations ({text})').format(text=file_type_string)
def required_icons(self): def required_icons(self):
""" """
@ -306,13 +307,13 @@ class PresentationMediaItem(MediaManagerItem):
os.path.join(doc.get_temp_folder(), 'mainslide001.png')): os.path.join(doc.get_temp_folder(), 'mainslide001.png')):
doc.load_presentation() doc.load_presentation()
i = 1 i = 1
image = os.path.join(doc.get_temp_folder(), 'mainslide%03d.png' % i) image = os.path.join(doc.get_temp_folder(), 'mainslide{number:0>3d}.png'.format(number=i))
thumbnail = os.path.join(doc.get_thumbnail_folder(), 'slide%d.png' % i) thumbnail = os.path.join(doc.get_thumbnail_folder(), 'slide%d.png' % i)
while os.path.isfile(image): while os.path.isfile(image):
service_item.add_from_image(image, name, thumbnail=thumbnail) service_item.add_from_image(image, name, thumbnail=thumbnail)
i += 1 i += 1
image = os.path.join(doc.get_temp_folder(), 'mainslide%03d.png' % i) image = os.path.join(doc.get_temp_folder(), 'mainslide{number:0>3d}.png'.format(number=i))
thumbnail = os.path.join(doc.get_thumbnail_folder(), 'slide%d.png' % i) thumbnail = os.path.join(doc.get_thumbnail_folder(), 'slide{number:d}.png'.format(number=i))
service_item.add_capability(ItemCapabilities.HasThumbnails) service_item.add_capability(ItemCapabilities.HasThumbnails)
doc.close_presentation() doc.close_presentation()
return True return True
@ -321,7 +322,8 @@ class PresentationMediaItem(MediaManagerItem):
if not remote: if not remote:
critical_error_message_box(translate('PresentationPlugin.MediaItem', 'Missing Presentation'), critical_error_message_box(translate('PresentationPlugin.MediaItem', 'Missing Presentation'),
translate('PresentationPlugin.MediaItem', translate('PresentationPlugin.MediaItem',
'The presentation %s no longer exists.') % filename) 'The presentation {name} no longer exists.'
).format(name=filename))
return False return False
else: else:
service_item.processor = self.display_type_combo_box.currentText() service_item.processor = self.display_type_combo_box.currentText()
@ -367,15 +369,16 @@ class PresentationMediaItem(MediaManagerItem):
critical_error_message_box(translate('PresentationPlugin.MediaItem', critical_error_message_box(translate('PresentationPlugin.MediaItem',
'Missing Presentation'), 'Missing Presentation'),
translate('PresentationPlugin.MediaItem', translate('PresentationPlugin.MediaItem',
'The presentation %s is incomplete, please reload.') 'The presentation {name} is incomplete, '
% filename) 'please reload.').format(name=filename))
return False return False
else: else:
# File is no longer present # File is no longer present
if not remote: if not remote:
critical_error_message_box(translate('PresentationPlugin.MediaItem', 'Missing Presentation'), critical_error_message_box(translate('PresentationPlugin.MediaItem', 'Missing Presentation'),
translate('PresentationPlugin.MediaItem', translate('PresentationPlugin.MediaItem',
'The presentation %s no longer exists.') % filename) 'The presentation {name} no longer exists.'
).format(name=filename))
return False return False
def find_controller_by_type(self, filename): def find_controller_by_type(self, filename):

View File

@ -48,14 +48,14 @@ class Controller(object):
self.is_live = live self.is_live = live
self.doc = None self.doc = None
self.hide_mode = None self.hide_mode = None
log.info('%s controller loaded' % live) log.info('{name} controller loaded'.format(name=live))
def add_handler(self, controller, file, hide_mode, slide_no): def add_handler(self, controller, file, hide_mode, slide_no):
""" """
Add a handler, which is an instance of a presentation and slidecontroller combination. If the slidecontroller Add a handler, which is an instance of a presentation and slidecontroller combination. If the slidecontroller
has a display then load the presentation. has a display then load the presentation.
""" """
log.debug('Live = %s, add_handler %s' % (self.is_live, file)) log.debug('Live = {live}, add_handler {handler}'.format(live=self.is_live, handler=file))
self.controller = controller self.controller = controller
if self.doc is not None: if self.doc is not None:
self.shutdown() self.shutdown()
@ -67,7 +67,7 @@ class Controller(object):
return return
self.doc.slidenumber = slide_no self.doc.slidenumber = slide_no
self.hide_mode = hide_mode self.hide_mode = hide_mode
log.debug('add_handler, slide_number: %d' % slide_no) log.debug('add_handler, slide_number: {slide:d}'.format(slide=slide_no))
if self.is_live: if self.is_live:
if hide_mode == HideMode.Screen: if hide_mode == HideMode.Screen:
Registry().execute('live_display_hide', HideMode.Screen) Registry().execute('live_display_hide', HideMode.Screen)
@ -87,14 +87,14 @@ class Controller(object):
""" """
Active the presentation, and show it on the screen. Use the last slide number. Active the presentation, and show it on the screen. Use the last slide number.
""" """
log.debug('Live = %s, activate' % self.is_live) log.debug('Live = {live}, activate'.format(live=self.is_live))
if not self.doc: if not self.doc:
return False return False
if self.doc.is_active(): if self.doc.is_active():
return True return True
if not self.doc.is_loaded(): if not self.doc.is_loaded():
if not self.doc.load_presentation(): if not self.doc.load_presentation():
log.warning('Failed to activate %s' % self.doc.file_path) log.warning('Failed to activate {path}'.format(path=self.doc.file_path))
return False return False
if self.is_live: if self.is_live:
self.doc.start_presentation() self.doc.start_presentation()
@ -105,14 +105,14 @@ class Controller(object):
if self.doc.is_active(): if self.doc.is_active():
return True return True
else: else:
log.warning('Failed to activate %s' % self.doc.file_path) log.warning('Failed to activate {path}'.format(path=self.doc.file_path))
return False return False
def slide(self, slide): def slide(self, slide):
""" """
Go to a specific slide Go to a specific slide
""" """
log.debug('Live = %s, slide' % self.is_live) log.debug('Live = {live}, slide'.format(live=self.is_live))
if not self.doc: if not self.doc:
return return
if not self.is_live: if not self.is_live:
@ -130,7 +130,7 @@ class Controller(object):
""" """
Based on the handler passed at startup triggers the first slide. Based on the handler passed at startup triggers the first slide.
""" """
log.debug('Live = %s, first' % self.is_live) log.debug('Live = {live}, first'.format(live=self.is_live))
if not self.doc: if not self.doc:
return return
if not self.is_live: if not self.is_live:
@ -148,7 +148,7 @@ class Controller(object):
""" """
Based on the handler passed at startup triggers the last slide. Based on the handler passed at startup triggers the last slide.
""" """
log.debug('Live = %s, last' % self.is_live) log.debug('Live = {live}, last'.format(live=self.is_live))
if not self.doc: if not self.doc:
return return
if not self.is_live: if not self.is_live:
@ -166,7 +166,7 @@ class Controller(object):
""" """
Based on the handler passed at startup triggers the next slide event. Based on the handler passed at startup triggers the next slide event.
""" """
log.debug('Live = %s, next' % self.is_live) log.debug('Live = {live}, next'.format(live=self.is_live))
if not self.doc: if not self.doc:
return return
if not self.is_live: if not self.is_live:
@ -191,7 +191,7 @@ class Controller(object):
""" """
Based on the handler passed at startup triggers the previous slide event. Based on the handler passed at startup triggers the previous slide event.
""" """
log.debug('Live = %s, previous' % self.is_live) log.debug('Live = {live}, previous'.formta(live=self.is_live))
if not self.doc: if not self.doc:
return return
if not self.is_live: if not self.is_live:
@ -212,7 +212,7 @@ class Controller(object):
""" """
Based on the handler passed at startup triggers slide show to shut down. Based on the handler passed at startup triggers slide show to shut down.
""" """
log.debug('Live = %s, shutdown' % self.is_live) log.debug('Live = {live}, shutdown'.format(live=self.is_live))
if not self.doc: if not self.doc:
return return
self.doc.close_presentation() self.doc.close_presentation()
@ -222,7 +222,7 @@ class Controller(object):
""" """
Instruct the controller to blank the presentation. Instruct the controller to blank the presentation.
""" """
log.debug('Live = %s, blank' % self.is_live) log.debug('Live = {live}, blank'.format(live=self.is_live))
self.hide_mode = hide_mode self.hide_mode = hide_mode
if not self.doc: if not self.doc:
return return
@ -243,7 +243,7 @@ class Controller(object):
""" """
Instruct the controller to stop and hide the presentation. Instruct the controller to stop and hide the presentation.
""" """
log.debug('Live = %s, stop' % self.is_live) log.debug('Live = {live}, stop'.format(live=self.is_live))
# The document has not been loaded yet, so don't do anything. This can happen when going live with a # The document has not been loaded yet, so don't do anything. This can happen when going live with a
# presentation while blanked to desktop. # presentation while blanked to desktop.
if not self.doc: if not self.doc:
@ -266,7 +266,7 @@ class Controller(object):
""" """
Instruct the controller to unblank the presentation. Instruct the controller to unblank the presentation.
""" """
log.debug('Live = %s, unblank' % self.is_live) log.debug('Live = {live}, unblank'.format(live=self.is_live))
self.hide_mode = None self.hide_mode = None
if not self.doc: if not self.doc:
return return
@ -321,7 +321,7 @@ class MessageListener(object):
""" """
Start of new presentation. Save the handler as any new presentations start here Start of new presentation. Save the handler as any new presentations start here
""" """
log.debug('Startup called with message %s' % message) log.debug('Startup called with message {text}'.format(text=message))
is_live = message[1] is_live = message[1]
item = message[0] item = message[0]
hide_mode = message[2] hide_mode = message[2]
@ -332,7 +332,7 @@ class MessageListener(object):
# the conversion has already been done at this point. # the conversion has already been done at this point.
file_type = os.path.splitext(file.lower())[1][1:] file_type = os.path.splitext(file.lower())[1][1:]
if file_type in PDF_CONTROLLER_FILETYPES: if file_type in PDF_CONTROLLER_FILETYPES:
log.debug('Converting from pdf/xps/oxps to images for serviceitem with file %s', file) log.debug('Converting from pdf/xps/oxps to images for serviceitem with file {name}'.format(name=file))
# Create a copy of the original item, and then clear the original item so it can be filled with images # Create a copy of the original item, and then clear the original item so it can be filled with images
item_cpy = copy.copy(item) item_cpy = copy.copy(item)
item.__init__(None) item.__init__(None)

View File

@ -87,7 +87,7 @@ class PdfController(PresentationController):
if found_gs: if found_gs:
program_type = 'gs' program_type = 'gs'
break break
log.debug('in check_binary, found: %s', program_type) log.debug('in check_binary, found: {text}'.format(text=program_type))
return program_type return program_type
def check_available(self): def check_available(self):
@ -255,11 +255,13 @@ class PdfDocument(PresentationDocument):
os.makedirs(self.get_temp_folder()) os.makedirs(self.get_temp_folder())
if self.controller.mudrawbin: if self.controller.mudrawbin:
log.debug('loading presentation using mudraw') log.debug('loading presentation using mudraw')
# TODO: Find out where the string conversion actually happens
runlog = check_output([self.controller.mudrawbin, '-w', str(size.width()), '-h', str(size.height()), runlog = check_output([self.controller.mudrawbin, '-w', str(size.width()), '-h', str(size.height()),
'-o', os.path.join(self.get_temp_folder(), 'mainslide%03d.png'), self.file_path], '-o', os.path.join(self.get_temp_folder(), 'mainslide%03d.png'), self.file_path],
startupinfo=self.startupinfo) startupinfo=self.startupinfo)
elif self.controller.mutoolbin: elif self.controller.mutoolbin:
log.debug('loading presentation using mutool') log.debug('loading presentation using mutool')
# TODO: Find out where the string convertsion actually happens
runlog = check_output([self.controller.mutoolbin, 'draw', '-w', str(size.width()), '-h', runlog = check_output([self.controller.mutoolbin, 'draw', '-w', str(size.width()), '-h',
str(size.height()), str(size.height()),
'-o', os.path.join(self.get_temp_folder(), 'mainslide%03d.png'), self.file_path], '-o', os.path.join(self.get_temp_folder(), 'mainslide%03d.png'), self.file_path],
@ -267,6 +269,7 @@ class PdfDocument(PresentationDocument):
elif self.controller.gsbin: elif self.controller.gsbin:
log.debug('loading presentation using gs') log.debug('loading presentation using gs')
resolution = self.gs_get_resolution(size) resolution = self.gs_get_resolution(size)
# TODO: Find out where the string conversion actually happens
runlog = check_output([self.controller.gsbin, '-dSAFER', '-dNOPAUSE', '-dBATCH', '-sDEVICE=png16m', runlog = check_output([self.controller.gsbin, '-dSAFER', '-dNOPAUSE', '-dBATCH', '-sDEVICE=png16m',
'-r' + str(resolution), '-dTextAlphaBits=4', '-dGraphicsAlphaBits=4', '-r' + str(resolution), '-dTextAlphaBits=4', '-dGraphicsAlphaBits=4',
'-sOutputFile=' + os.path.join(self.get_temp_folder(), 'mainslide%03d.png'), '-sOutputFile=' + os.path.join(self.get_temp_folder(), 'mainslide%03d.png'),

View File

@ -179,7 +179,7 @@ class PowerpointDocument(PresentationDocument):
if not self.presentation.Slides(num + 1).SlideShowTransition.Hidden: if not self.presentation.Slides(num + 1).SlideShowTransition.Hidden:
self.index_map[key] = num + 1 self.index_map[key] = num + 1
self.presentation.Slides(num + 1).Export( self.presentation.Slides(num + 1).Export(
os.path.join(self.get_thumbnail_folder(), 'slide%d.png' % (key)), 'png', 320, 240) os.path.join(self.get_thumbnail_folder(), 'slide{key:d}.png'.format(key=key)), 'png', 320, 240)
key += 1 key += 1
self.slide_count = key - 1 self.slide_count = key - 1
@ -345,8 +345,9 @@ class PowerpointDocument(PresentationDocument):
# Find the presentation window and save the handle for later # Find the presentation window and save the handle for later
self.presentation_hwnd = None self.presentation_hwnd = None
if ppt_window: if ppt_window:
log.debug('main display size: y=%d, height=%d, x=%d, width=%d' log.debug('main display size: y={y:d}, height={height:d}, '
% (size.y(), size.height(), size.x(), size.width())) 'x={x:d}, width={width:d}'.format(y=size.y(), height=size.height(),
x=size.x(), width=size.width()))
win32gui.EnumWindows(self._window_enum_callback, size) win32gui.EnumWindows(self._window_enum_callback, size)
# Make sure powerpoint doesn't steal focus, unless we're on a single screen setup # Make sure powerpoint doesn't steal focus, unless we're on a single screen setup
if len(ScreenList().screen_list) > 1: if len(ScreenList().screen_list) > 1:
@ -361,10 +362,18 @@ class PowerpointDocument(PresentationDocument):
# it is the powerpoint presentation window. # it is the powerpoint presentation window.
(left, top, right, bottom) = win32gui.GetWindowRect(hwnd) (left, top, right, bottom) = win32gui.GetWindowRect(hwnd)
window_title = win32gui.GetWindowText(hwnd) window_title = win32gui.GetWindowText(hwnd)
log.debug('window size: left=%d, top=%d, right=%d, width=%d' % (left, top, right, bottom)) log.debug('window size: left=left:d}, top={top:d}, '
log.debug('compare size: %d and %d, %d and %d, %d and %d, %d and %d' 'right={right:d}, bottom={bottom:d}'.format(left=left, top=top, right=right, bottom=bottom))
% (size.y(), top, size.height(), (bottom - top), size.x(), left, size.width(), (right - left))) log.debug('compare size: {y:d} and {top:d}, {height:d} and {vertical:d}, '
log.debug('window title: %s' % window_title) '{x:d} and {left}, {width:d} and {horizontal:d}'.format(y=size.y(),
top=top,
height=size.height(),
vertical=(bottom - top),
x=size.x(),
left=left,
width=size.width(),
horizontal=(right - left)))
log.debug('window title: {title}'.format(title=window_title))
filename_root, filename_ext = os.path.splitext(os.path.basename(self.file_path)) filename_root, filename_ext = os.path.splitext(os.path.basename(self.file_path))
if size.y() == top and size.height() == (bottom - top) and size.x() == left and \ if size.y() == top and size.height() == (bottom - top) and size.x() == left and \
size.width() == (right - left) and filename_root in window_title: size.width() == (right - left) and filename_root in window_title:
@ -416,8 +425,8 @@ class PowerpointDocument(PresentationDocument):
and self.get_slide_number() == slide_no: and self.get_slide_number() == slide_no:
click_index = self.presentation.SlideShowWindow.View.GetClickIndex() click_index = self.presentation.SlideShowWindow.View.GetClickIndex()
click_count = self.presentation.SlideShowWindow.View.GetClickCount() click_count = self.presentation.SlideShowWindow.View.GetClickCount()
log.debug('We are already on this slide - go to next effect if any left, idx: %d, count: %d' log.debug('We are already on this slide - go to next effect if any left, idx: '
% (click_index, click_count)) '{index:d}, count: {count:d}'.format(index=click_index, count=click_count))
if click_index < click_count: if click_index < click_count:
self.next_step() self.next_step()
else: else:

View File

@ -148,7 +148,7 @@ class PptviewDocument(PresentationDocument):
return return
log.debug('create_thumbnails proceeding') log.debug('create_thumbnails proceeding')
for idx in range(self.get_slide_count()): for idx in range(self.get_slide_count()):
path = '%s\\slide%s.bmp' % (self.get_temp_folder(), str(idx + 1)) path = '{folder}\\slide{index}.bmp'.format(folder=self.get_temp_folder(), index=str(idx + 1))
self.convert_thumbnail(path, idx + 1) self.convert_thumbnail(path, idx + 1)
def create_titles_and_notes(self): def create_titles_and_notes(self):

View File

@ -278,7 +278,7 @@ class PresentationDocument(object):
prefix = 'live' prefix = 'live'
else: else:
prefix = 'preview' prefix = 'preview'
Registry().execute('slidecontroller_%s_change' % prefix, self.slide_number - 1) Registry().execute('slidecontroller_{prefix}_change'.format(prefix=prefix), self.slide_number - 1)
def get_slide_text(self, slide_no): def get_slide_text(self, slide_no):
""" """
@ -312,7 +312,7 @@ class PresentationDocument(object):
log.exception('Failed to open/read existing titles file') log.exception('Failed to open/read existing titles file')
titles = [] titles = []
for slide_no, title in enumerate(titles, 1): for slide_no, title in enumerate(titles, 1):
notes_file = os.path.join(self.get_thumbnail_folder(), 'slideNotes%d.txt' % slide_no) notes_file = os.path.join(self.get_thumbnail_folder(), 'slideNotes{number:d}.txt'.format(number=slide_no))
note = '' note = ''
if os.path.exists(notes_file): if os.path.exists(notes_file):
try: try:
@ -335,7 +335,8 @@ class PresentationDocument(object):
fo.writelines(titles) fo.writelines(titles)
if notes: if notes:
for slide_no, note in enumerate(notes, 1): for slide_no, note in enumerate(notes, 1):
notes_file = os.path.join(self.get_thumbnail_folder(), 'slideNotes%d.txt' % slide_no) notes_file = os.path.join(self.get_thumbnail_folder(),
'slideNotes{number:d}.txt'.format(number=slide_no))
with open(notes_file, mode='wt', encoding='utf-8') as fn: with open(notes_file, mode='wt', encoding='utf-8') as fn:
fn.write(note) fn.write(note)

View File

@ -137,7 +137,8 @@ class PresentationTab(SettingsTab):
if checkbox.isEnabled(): if checkbox.isEnabled():
checkbox.setText(controller.name) checkbox.setText(controller.name)
else: else:
checkbox.setText(translate('PresentationPlugin.PresentationTab', '%s (unavailable)') % controller.name) checkbox.setText(translate('PresentationPlugin.PresentationTab',
'{name} (unavailable)').format(name=controller.name))
def load(self): def load(self):
""" """

View File

@ -128,11 +128,11 @@ class PresentationPlugin(Plugin):
path = os.path.join(controller_dir, filename) path = os.path.join(controller_dir, filename)
if os.path.isfile(path): if os.path.isfile(path):
module_name = 'openlp.plugins.presentations.lib.' + os.path.splitext(filename)[0] module_name = 'openlp.plugins.presentations.lib.' + os.path.splitext(filename)[0]
log.debug('Importing controller %s', module_name) log.debug('Importing controller {name}'.format(name=module_name))
try: try:
__import__(module_name, globals(), locals(), []) __import__(module_name, globals(), locals(), [])
except ImportError: except ImportError:
log.warning('Failed to import %s on path %s', module_name, path) log.warning('Failed to import {name} on path {path}'.format(name=module_name, path=path))
controller_classes = PresentationController.__subclasses__() controller_classes = PresentationController.__subclasses__()
for controller_class in controller_classes: for controller_class in controller_classes:
controller = controller_class(self) controller = controller_class(self)

View File

@ -250,3 +250,17 @@ class TestPJLink(TestCase):
# THEN: Shutter should be closed and mute should be True # THEN: Shutter should be closed and mute should be True
self.assertTrue(pjlink.shutter, 'Shutter should have been set to closed') self.assertTrue(pjlink.shutter, 'Shutter should have been set to closed')
self.assertTrue(pjlink.mute, 'Audio should be on') self.assertTrue(pjlink.mute, 'Audio should be on')
def projector_process_input_test(self):
"""
Test input source status shows current input
"""
# GIVEN: Test object
pjlink = pjlink_test
pjlink.source = '0'
# WHEN: Called with input source
pjlink.process_inpt('1')
# THEN: Input selected should reflect current input
self.assertEquals(pjlink.source, '1', 'Input source should be set to "1"')