From 3c69631b592067e20bed2ef383e300cc0563383f Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 7 Jul 2012 16:54:14 +0200 Subject: [PATCH] clean ups --- openlp/core/ui/servicemanager.py | 6 +++--- openlp/plugins/presentations/lib/impresscontroller.py | 3 --- openlp/plugins/presentations/lib/powerpointcontroller.py | 5 +---- openlp/plugins/presentations/lib/pptviewcontroller.py | 3 --- .../plugins/presentations/lib/presentationcontroller.py | 9 +++------ openlp/plugins/songs/forms/editsongform.py | 5 ++--- openlp/plugins/songs/lib/mediaitem.py | 6 +++--- openlp/plugins/songs/lib/songimport.py | 5 ++--- 8 files changed, 14 insertions(+), 28 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 0ffb1fff7..d7f745fca 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -39,7 +39,8 @@ log = logging.getLogger(__name__) from PyQt4 import QtCore, QtGui from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, build_icon, \ - ItemCapabilities, SettingsManager, translate, str_to_bool + ItemCapabilities, SettingsManager, translate, str_to_bool, \ + check_directory_exists from openlp.core.lib.theme import ThemeLevel from openlp.core.lib.settings import Settings from openlp.core.lib.ui import UiStrings, critical_error_message_box, \ @@ -556,8 +557,7 @@ class ServiceManager(QtGui.QWidget): audio_from = os.path.join(self.servicePath, audio_from) save_file = os.path.join(self.servicePath, audio_to) save_path = os.path.split(save_file)[0] - if not os.path.exists(save_path): - os.makedirs(save_path) + check_directory_exists(save_path) if not os.path.exists(save_file): shutil.copy(audio_from, save_file) zip.write(audio_from, audio_to.encode(u'utf-8')) diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 1a8754f80..a85f43592 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -227,9 +227,6 @@ class ImpressDocument(PresentationDocument): OpenOffice task started earlier. If OpenOffice is not present is is started. Once the environment is available the presentation is loaded and started. - - ``presentation`` - The file name of the presentatios to the run. """ log.debug(u'Load Presentation OpenOffice') if os.name == u'nt': diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index fcdb5b105..54b9c2144 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -119,10 +119,7 @@ class PowerpointDocument(PresentationDocument): def load_presentation(self): """ Called when a presentation is added to the SlideController. - Opens the PowerPoint file using the process created earlier - - ``presentation`` - The file name of the presentations to run. + Opens the PowerPoint file using the process created earlier. """ log.debug(u'load_presentation') if not self.controller.process or not self.controller.process.Visible: diff --git a/openlp/plugins/presentations/lib/pptviewcontroller.py b/openlp/plugins/presentations/lib/pptviewcontroller.py index 8f068fa05..2e3b28f6e 100644 --- a/openlp/plugins/presentations/lib/pptviewcontroller.py +++ b/openlp/plugins/presentations/lib/pptviewcontroller.py @@ -118,9 +118,6 @@ class PptviewDocument(PresentationDocument): Called when a presentation is added to the SlideController. It builds the environment, starts communcations with the background PptView task started earlier. - - ``presentation`` - The file name of the presentations to run. """ log.debug(u'LoadPresentation') renderer = self.controller.plugin.renderer diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index e8e49d2e8..b72e1e9d4 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -47,7 +47,7 @@ class PresentationDocument(object): **Hook Functions** - ``load_presentation(presentation)`` + ``load_presentation()`` Load a presentation file ``close_presentation()`` @@ -104,11 +104,8 @@ class PresentationDocument(object): def load_presentation(self): """ - Called when a presentation is added to the SlideController. - Loads the presentation and starts it - - ``presentation`` - The file name of the presentations to the run. + Called when a presentation is added to the SlideController. Loads the + presentation and starts it. Returns False if the file could not be opened """ diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index e3ed07aba..0b3dddcc9 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -34,7 +34,7 @@ import shutil from PyQt4 import QtCore, QtGui from openlp.core.lib import PluginStatus, Receiver, MediaType, translate, \ - create_separated_list + create_separated_list, check_directory_exists from openlp.core.lib.ui import UiStrings, set_case_insensitive_completer, \ critical_error_message_box, find_and_set_in_combo_box from openlp.core.utils import AppLocation @@ -880,8 +880,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): save_path = os.path.join( AppLocation.get_section_data_path(self.mediaitem.plugin.name), 'audio', str(self.song.id)) - if not os.path.exists(save_path): - os.makedirs(save_path) + check_directory_exists(save_path) self.song.media_files = [] files = [] for row in xrange(self.audioListWidget.count()): diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 47e9ba742..88999dce4 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -36,7 +36,8 @@ from PyQt4 import QtCore, QtGui from sqlalchemy.sql import or_ from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \ - translate, check_item_selected, PluginStatus, create_separated_list + translate, check_item_selected, PluginStatus, create_separated_list, \ + check_directory_exists from openlp.core.lib.ui import UiStrings, create_widget_action from openlp.core.lib.settings import Settings from openlp.core.utils import AppLocation @@ -89,8 +90,7 @@ class SongMediaItem(MediaManagerItem): dest_file = os.path.join( AppLocation.get_section_data_path(self.plugin.name), u'audio', str(song.id), os.path.split(bga)[1]) - if not os.path.exists(os.path.split(dest_file)[0]): - os.makedirs(os.path.split(dest_file)[0]) + check_directory_exists(os.path.split(dest_file)[0]) shutil.copyfile(os.path.join( AppLocation.get_section_data_path( u'servicemanager'), bga), diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index 8dcf4e9f3..134cbdfdc 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -33,7 +33,7 @@ import os from PyQt4 import QtCore -from openlp.core.lib import Receiver, translate +from openlp.core.lib import Receiver, translate, check_directory_exists from openlp.core.ui.wizard import WizardStrings from openlp.core.utils import AppLocation from openlp.plugins.songs.lib import clean_song, VerseType @@ -388,8 +388,7 @@ class SongImport(QtCore.QObject): AppLocation.get_section_data_path( self.importWizard.plugin.name), 'audio', str(song_id)) - if not os.path.exists(self.save_path): - os.makedirs(self.save_path) + check_directory_exists(self.save_path) if not filename.startswith(self.save_path): oldfile, filename = filename, os.path.join(self.save_path, os.path.split(filename)[1])