openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #04221
[Merge] lp:~raoul-snyman/openlp/documentation into lp:openlp
Raoul Snyman has proposed merging lp:~raoul-snyman/openlp/documentation into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
Updated documentation.
Renamed the import wizards to match the general form naming convention.
Removed an unnecessary class.
--
https://code.launchpad.net/~raoul-snyman/openlp/documentation/+merge/38628
Your team OpenLP Core is requested to review the proposed merge of lp:~raoul-snyman/openlp/documentation into lp:openlp.
=== modified file 'documentation/api/source/plugins/bibles.rst'
--- documentation/api/source/plugins/bibles.rst 2010-10-11 20:47:00 +0000
+++ documentation/api/source/plugins/bibles.rst 2010-10-16 19:43:40 +0000
@@ -6,93 +6,50 @@
.. automodule:: openlp.plugins.bibles
:members:
-:mod:`BiblePlugin` Class
--------------------------
+Plugin Class
+------------
.. autoclass:: openlp.plugins.bibles.bibleplugin.BiblePlugin
:members:
-:mod:`forms` Submodule
-----------------------
+Forms
+-----
.. automodule:: openlp.plugins.bibles.forms
:members:
-:mod:`BibleImportWizard`
-^^^^^^^^^^^^^^^^^^^^^^^^
-
-.. autoclass:: openlp.plugins.bibles.forms.bibleimportwizard.Ui_BibleImportWizard
- :members:
-
.. autoclass:: openlp.plugins.bibles.forms.importwizardform.ImportWizardForm
:members:
-:mod:`lib` Submodule
---------------------
+Helper Classes & Functions
+--------------------------
.. automodule:: openlp.plugins.bibles.lib
:members:
-:mod:`db`
-^^^^^^^^^
-
.. automodule:: openlp.plugins.bibles.lib.db
:members:
-.. autoclass:: openlp.plugins.bibles.lib.db.BibleDB
- :members:
-
-:mod:`csv`
-^^^^^^^^^^
+.. automodule:: openlp.plugins.bibles.lib.biblestab
+ :members:
+
+.. automodule:: openlp.plugins.bibles.lib.manager
+ :members:
+
+.. automodule:: openlp.plugins.bibles.lib.mediaitem
+ :members:
+
+Bible Importers
+---------------
.. automodule:: openlp.plugins.bibles.lib.csvbible
:members:
-.. autoclass:: openlp.plugins.bibles.lib.csvbible.CSVBible
- :members:
-
-:mod:`http`
-^^^^^^^^^^^
-
.. automodule:: openlp.plugins.bibles.lib.http
:members:
-.. autoclass:: openlp.plugins.bibles.lib.http.HTTPBible
- :members:
-
-:mod:`osis`
-^^^^^^^^^^^
-
.. automodule:: openlp.plugins.bibles.lib.osis
:members:
-.. autoclass:: openlp.plugins.bibles.lib.osis.OSISBible
- :members:
-
-:mod:`opensong`
-^^^^^^^^^^^^^^^
-
.. automodule:: openlp.plugins.bibles.lib.opensong
:members:
-
-.. autoclass:: openlp.plugins.bibles.lib.opensong.OpenSongBible
- :members:
-
-:mod:`biblestab`
-^^^^^^^^^^^^^^^^
-
-.. automodule:: openlp.plugins.bibles.lib.biblestab
- :members:
-
-:mod:`manager`
-^^^^^^^^^^^^^^
-
-.. automodule:: openlp.plugins.bibles.lib.manager
- :members:
-
-:mod:`mediaitem`
-^^^^^^^^^^^^^^^^
-
-.. automodule:: openlp.plugins.bibles.lib.mediaitem
- :members:
-
=== modified file 'documentation/api/source/plugins/images.rst'
--- documentation/api/source/plugins/images.rst 2010-10-15 15:25:39 +0000
+++ documentation/api/source/plugins/images.rst 2010-10-16 19:43:40 +0000
@@ -3,6 +3,9 @@
Images Plugin
=============
+.. automodule:: openlp.plugins.images
+ :members:
+
Plugin Class
------------
=== modified file 'documentation/api/source/plugins/media.rst'
--- documentation/api/source/plugins/media.rst 2010-10-11 20:47:00 +0000
+++ documentation/api/source/plugins/media.rst 2010-10-16 19:43:40 +0000
@@ -6,3 +6,17 @@
.. automodule:: openlp.plugins.media
:members:
+Plugin Class
+------------
+
+.. autoclass:: openlp.plugins.media.mediaplugin.MediaPlugin
+ :members:
+
+Helper Classes & Functions
+--------------------------
+
+.. automodule:: openlp.plugins.media.lib
+ :members:
+
+.. automodule:: openlp.plugins.media.lib.mediaitem
+ :members:
=== modified file 'documentation/api/source/plugins/songs.rst'
--- documentation/api/source/plugins/songs.rst 2010-10-11 20:47:00 +0000
+++ documentation/api/source/plugins/songs.rst 2010-10-16 19:43:40 +0000
@@ -6,89 +6,68 @@
.. automodule:: openlp.plugins.songs
:members:
-:class:`SongsPlugin` Class
---------------------------
+Plugin Class
+------------
.. autoclass:: openlp.plugins.songs.songsplugin.SongsPlugin
:members:
-:mod:`forms` Submodule
-----------------------
+Forms
+-----
.. automodule:: openlp.plugins.songs.forms
:members:
-:class:`AuthorsForm`
-^^^^^^^^^^^^^^^^^^^^
-
-.. autoclass:: openlp.plugins.songs.forms.authorsdialog.Ui_AuthorsDialog
- :members:
-
.. autoclass:: openlp.plugins.songs.forms.authorsform.AuthorsForm
:members:
-:class:`EditSongForm`
-^^^^^^^^^^^^^^^^^^^^^
-
-.. autoclass:: openlp.plugins.songs.forms.editsongdialog.Ui_EditSongDialog
- :members:
-
.. autoclass:: openlp.plugins.songs.forms.editsongform.EditSongForm
:members:
-:class:`EditVerseForm`
-^^^^^^^^^^^^^^^^^^^^^^
-
-.. autoclass:: openlp.plugins.songs.forms.editversedialog.Ui_EditVerseDialog
- :members:
-
.. autoclass:: openlp.plugins.songs.forms.editverseform.EditVerseForm
:members:
-:class:`SongBookForm`
-^^^^^^^^^^^^^^^^^^^^^
-
-.. autoclass:: openlp.plugins.songs.forms.songbookdialog.Ui_SongBookDialog
- :members:
-
.. autoclass:: openlp.plugins.songs.forms.songbookform.SongBookForm
:members:
-:class:`SongImportForm`
-^^^^^^^^^^^^^^^^^^^^^^^
-
-.. autoclass:: openlp.plugins.songs.forms.songimportwizard.Ui_SongImportWizard
- :members:
-
-.. autoclass:: openlp.plugins.songs.forms.songimportform.ImportWizardForm
- :members:
-
-:class:`SongMaintenanceForm`
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-.. autoclass:: openlp.plugins.songs.forms.songmaintenancedialog.Ui_SongMaintenanceDialog
+.. autoclass:: openlp.plugins.songs.forms.songimportform.SongImportForm
:members:
.. autoclass:: openlp.plugins.songs.forms.songmaintenanceform.SongMaintenanceForm
:members:
-:class:`TopicsForm`
-^^^^^^^^^^^^^^^^^^^
-
-.. autoclass:: openlp.plugins.songs.forms.topicsdialog.Ui_TopicsDialog
- :members:
-
.. autoclass:: openlp.plugins.songs.forms.topicsform.TopicsForm
:members:
-:mod:`lib` Submodule
---------------------
+Helper Classes & Functions
+--------------------------
.. automodule:: openlp.plugins.songs.lib
:members:
-:mod:`cclifileimport` Submodule
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+.. automodule:: openlp.plugins.songs.lib.db
+ :members:
+
+.. automodule:: openlp.plugins.songs.lib.importer
+ :members:
+
+.. automodule:: openlp.plugins.songs.lib.mediaitem
+ :members:
+
+.. autoclass:: openlp.plugins.songs.lib.mediaitem.SongListView
+ :members:
+
+.. automodule:: openlp.plugins.songs.lib.songimport
+ :members:
+
+.. automodule:: openlp.plugins.songs.lib.songstab
+ :members:
+
+.. automodule:: openlp.plugins.songs.lib.xml
+ :members:
+
+Song Importers
+--------------
.. automodule:: openlp.plugins.songs.lib.cclifileimport
:members:
@@ -96,98 +75,29 @@
.. autoclass:: openlp.plugins.songs.lib.cclifileimport.CCLIFileImportError
:members:
-:mod:`db` Submodule
-^^^^^^^^^^^^^^^^^^^
-
-.. automodule:: openlp.plugins.songs.lib.db
- :members:
-
-:mod:`ewimport` Submodule
-^^^^^^^^^^^^^^^^^^^^^^^^^
-
.. automodule:: openlp.plugins.songs.lib.ewimport
:members:
.. autoclass:: openlp.plugins.songs.lib.ewimport.FieldDescEntry
:members:
-:mod:`importer` Submodule
-^^^^^^^^^^^^^^^^^^^^^^^^^
-
-.. automodule:: openlp.plugins.songs.lib.importer
- :members:
-
-:mod:`mediaitem` Submodule
-^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-.. automodule:: openlp.plugins.songs.lib.mediaitem
- :members:
-
-.. autoclass:: openlp.plugins.songs.lib.mediaitem.SongListView
- :members:
-
-:mod:`olp1import` Submodule
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
.. automodule:: openlp.plugins.songs.lib.olp1import
:members:
-:mod:`olpimport` Submodule
-^^^^^^^^^^^^^^^^^^^^^^^^^^
-
.. automodule:: openlp.plugins.songs.lib.olpimport
:members:
-:mod:`oooimport` Submodule
-^^^^^^^^^^^^^^^^^^^^^^^^^^
-
.. automodule:: openlp.plugins.songs.lib.oooimport
:members:
-:mod:`opensongimport` Submodule
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
.. automodule:: openlp.plugins.songs.lib.opensongimport
:members:
-:mod:`sofimport` Submodule
-^^^^^^^^^^^^^^^^^^^^^^^^^^
-
.. automodule:: openlp.plugins.songs.lib.sofimport
:members:
-:mod:`songbeamerimport` Submodule
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
.. automodule:: openlp.plugins.songs.lib.songbeamerimport
:members:
-:mod:`songimport` Submodule
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-.. automodule:: openlp.plugins.songs.lib.songimport
- :members:
-
-:mod:`songstab` Submodule
-^^^^^^^^^^^^^^^^^^^^^^^^^
-
-.. automodule:: openlp.plugins.songs.lib.songstab
- :members:
-
-:mod:`wowimport` Submodule
-^^^^^^^^^^^^^^^^^^^^^^^^^^
-
.. automodule:: openlp.plugins.songs.lib.wowimport
:members:
-
-:mod:`songxml` Submodule
-^^^^^^^^^^^^^^^^^^^^^^^^
-
-.. automodule:: openlp.plugins.songs.lib.songxml
- :members:
-
-:mod:`xml` Submodule
-^^^^^^^^^^^^^^^^^^^^
-
-.. automodule:: openlp.plugins.songs.lib.xml
- :members:
=== modified file 'documentation/manual/source/conf.py'
--- documentation/manual/source/conf.py 2010-10-15 20:09:57 +0000
+++ documentation/manual/source/conf.py 2010-10-16 19:43:40 +0000
@@ -200,3 +200,9 @@
# If false, no module index is generated.
#latex_use_modindex = True
+
+# A dictionary that contains LaTeX snippets that override those Sphinx usually
+# puts into the generated .tex files.
+latex_elements = {
+ 'fontpkg': '\\usepackage{helvet}'
+}
=== modified file 'openlp/plugins/bibles/forms/__init__.py'
--- openlp/plugins/bibles/forms/__init__.py 2010-09-14 18:18:47 +0000
+++ openlp/plugins/bibles/forms/__init__.py 2010-10-16 19:43:40 +0000
@@ -24,6 +24,33 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
-from importwizardform import ImportWizardForm
-
-__all__ = ['ImportWizardForm']
+"""
+Forms in OpenLP are made up of two classes. One class holds all the graphical
+elements, like buttons and lists, and the other class holds all the functional
+code, like slots and loading and saving.
+
+The first class, commonly known as the **Dialog** class, is typically named
+``Ui_<name>Dialog``. It is a slightly modified version of the class that the
+``pyuic4`` command produces from Qt4's .ui file. Typical modifications will be
+converting most strings from "" to u'' and using OpenLP's ``translate()``
+function for translating strings.
+
+The second class, commonly known as the **Form** class, is typically named
+``<name>Form``. This class is the one which is instantiated and used. It uses
+dual inheritance to inherit from (usually) QtGui.QDialog and the Ui class
+mentioned above, like so::
+
+ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
+
+ def __init__(self, parent, manager, bibleplugin):
+ QtGui.QWizard.__init__(self, parent)
+ self.setupUi(self)
+
+This allows OpenLP to use ``self.object`` for all the GUI elements while keeping
+them separate from the functionality, so that it is easier to recreate the GUI
+from the .ui files later if necessary.
+"""
+
+from bibleimportform import BibleImportForm
+
+__all__ = ['BibleImportForm']
=== renamed file 'openlp/plugins/bibles/forms/importwizardform.py' => 'openlp/plugins/bibles/forms/bibleimportform.py'
--- openlp/plugins/bibles/forms/importwizardform.py 2010-10-08 17:07:49 +0000
+++ openlp/plugins/bibles/forms/bibleimportform.py 2010-10-16 19:43:40 +0000
@@ -54,7 +54,7 @@
return cls.Names[name]
-class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
+class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
"""
This is the Bible Import Wizard, which allows easy importing of Bibles
into OpenLP from other formats like OSIS, CSV and OpenSong.
=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py 2010-10-08 17:37:34 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py 2010-10-16 19:43:40 +0000
@@ -31,7 +31,7 @@
from openlp.core.lib import MediaManagerItem, Receiver, BaseListWithDnD, \
ItemCapabilities, translate
-from openlp.plugins.bibles.forms import ImportWizardForm
+from openlp.plugins.bibles.forms import BibleImportForm
from openlp.plugins.bibles.lib.db import BibleDB
log = logging.getLogger(__name__)
@@ -362,7 +362,7 @@
def onImportClick(self):
if not hasattr(self, u'import_wizard'):
- self.import_wizard = ImportWizardForm(self, self.parent.manager,
+ self.import_wizard = BibleImportForm(self, self.parent.manager,
self.parent)
self.import_wizard.exec_()
self.reloadBibles()
=== modified file 'openlp/plugins/songs/forms/__init__.py'
--- openlp/plugins/songs/forms/__init__.py 2010-09-14 18:18:47 +0000
+++ openlp/plugins/songs/forms/__init__.py 2010-10-16 19:43:40 +0000
@@ -24,10 +24,37 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
+"""
+Forms in OpenLP are made up of two classes. One class holds all the graphical
+elements, like buttons and lists, and the other class holds all the functional
+code, like slots and loading and saving.
+
+The first class, commonly known as the **Dialog** class, is typically named
+``Ui_<name>Dialog``. It is a slightly modified version of the class that the
+``pyuic4`` command produces from Qt4's .ui file. Typical modifications will be
+converting most strings from "" to u'' and using OpenLP's ``translate()``
+function for translating strings.
+
+The second class, commonly known as the **Form** class, is typically named
+``<name>Form``. This class is the one which is instantiated and used. It uses
+dual inheritance to inherit from (usually) QtGui.QDialog and the Ui class
+mentioned above, like so::
+
+ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
+
+ def __init__(self, parent=None):
+ QtGui.QDialog.__init__(self, parent)
+ self.setupUi(self)
+
+This allows OpenLP to use ``self.object`` for all the GUI elements while keeping
+them separate from the functionality, so that it is easier to recreate the GUI
+from the .ui files later if necessary.
+"""
+
from authorsform import AuthorsForm
from topicsform import TopicsForm
from songbookform import SongBookForm
from editverseform import EditVerseForm
from editsongform import EditSongForm
from songmaintenanceform import SongMaintenanceForm
-from songimportform import ImportWizardForm
+from songimportform import SongImportForm
=== modified file 'openlp/plugins/songs/forms/songimportform.py'
--- openlp/plugins/songs/forms/songimportform.py 2010-10-08 06:16:01 +0000
+++ openlp/plugins/songs/forms/songimportform.py 2010-10-16 19:43:40 +0000
@@ -35,7 +35,7 @@
log = logging.getLogger(__name__)
-class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
+class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
"""
This is the Song Import Wizard, which allows easy importing of Songs
into OpenLP from other formats like OpenLyrics, OpenSong and CCLI.
@@ -248,7 +248,7 @@
# Progress page
return True
- def getFileName(self, title, editbox,
+ def getFileName(self, title, editbox,
filters = '%s (*)' % translate('SongsPlugin.ImportWizardForm',
'All Files')):
filename = QtGui.QFileDialog.getOpenFileName(self, title,
@@ -260,7 +260,7 @@
self.plugin.settingsSection,
os.path.split(unicode(filename))[0], 1)
- def getFiles(self, title, listbox,
+ def getFiles(self, title, listbox,
filters = u'%s (*)' % translate('SongsPlugin.ImportWizardForm',
'All Files')):
filenames = QtGui.QFileDialog.getOpenFileNames(self, title,
@@ -290,7 +290,7 @@
self.openLP2FilenameEdit,
u'%s (*.sqlite);;%s (*)'
% (translate('SongsPlugin.ImportWizardForm',
- 'OpenLP 2.0 Databases'),
+ 'OpenLP 2.0 Databases'),
translate('SongsPlugin.ImportWizardForm',
'All Files'))
)
@@ -299,10 +299,10 @@
self.getFileName(
translate('SongsPlugin.ImportWizardForm',
'Select openlp.org 1.x Database File'),
- self.openLP1FilenameEdit,
+ self.openLP1FilenameEdit,
u'%s (*.olp);;%s (*)'
% (translate('SongsPlugin.ImportWizardForm',
- 'openlp.org v1.x Databases'),
+ 'openlp.org v1.x Databases'),
translate('SongsPlugin.ImportWizardForm',
'All Files'))
)
@@ -331,10 +331,10 @@
self.getFiles(
translate('SongsPlugin.ImportWizardForm',
'Select Words of Worship Files'),
- self.wordsOfWorshipFileListWidget,
+ self.wordsOfWorshipFileListWidget,
u'%s (*.wsg *.wow-song);;%s (*)'
% (translate('SongsPlugin.ImportWizardForm',
- 'Words Of Worship Song Files'),
+ 'Words Of Worship Song Files'),
translate('SongsPlugin.ImportWizardForm',
'All Files'))
)
@@ -356,10 +356,10 @@
self.getFiles(
translate('SongsPlugin.ImportWizardForm',
'Select Songs of Fellowship Files'),
- self.songsOfFellowshipFileListWidget,
+ self.songsOfFellowshipFileListWidget,
u'%s (*.rtf);;%s (*)'
% (translate('SongsPlugin.ImportWizardForm',
- 'Songs Of Felloship Song Files'),
+ 'Songs Of Felloship Song Files'),
translate('SongsPlugin.ImportWizardForm',
'All Files'))
)
=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py 2010-10-06 20:24:53 +0000
+++ openlp/plugins/songs/lib/mediaitem.py 2010-10-16 19:43:40 +0000
@@ -31,7 +31,7 @@
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, Receiver, \
ItemCapabilities, translate, check_item_selected
from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, \
- ImportWizardForm
+ SongImportForm
from openlp.plugins.songs.lib import SongXMLParser
from openlp.plugins.songs.lib.db import Author, Song
@@ -254,7 +254,7 @@
def onImportClick(self):
if not hasattr(self, u'import_wizard'):
- self.import_wizard = ImportWizardForm(self, self.parent)
+ self.import_wizard = SongImportForm(self, self.parent)
self.import_wizard.exec_()
Receiver.send_message(u'songs_load_list')
=== removed file 'openlp/plugins/songs/lib/songxml.py'
--- openlp/plugins/songs/lib/songxml.py 2010-10-10 21:13:10 +0000
+++ openlp/plugins/songs/lib/songxml.py 1970-01-01 00:00:00 +0000
@@ -1,423 +0,0 @@
-# -*- coding: utf-8 -*-
-# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
-
-###############################################################################
-# OpenLP - Open Source Lyrics Projection #
-# --------------------------------------------------------------------------- #
-# Copyright (c) 2008-2010 Raoul Snyman #
-# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
-# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
-# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
-# Carsten Tinggaard, Frode Woldsund #
-# --------------------------------------------------------------------------- #
-# This program is free software; you can redistribute it and/or modify it #
-# under the terms of the GNU General Public License as published by the Free #
-# Software Foundation; version 2 of the License. #
-# #
-# This program is distributed in the hope that it will be useful, but WITHOUT #
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
-# more details. #
-# #
-# You should have received a copy of the GNU General Public License along #
-# with this program; if not, write to the Free Software Foundation, Inc., 59 #
-# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
-###############################################################################
-
-import logging
-
-from types import ListType
-
-log = logging.getLogger(__name__)
-
-class SongException(Exception):
- pass
-
-class SongTitleError(SongException):
- pass
-
-class SongTypeError(SongException):
- pass
-
-class SongSlideError(SongException):
- pass
-
-class SongFeatureError(SongException):
- pass
-
-# TODO: Song: Logging - not all, but enough
-# TODO: Song: Handle OpenLP2 format
-# TODO: Song: Import OpenLP1
-# TODO: Song: Export OpenLP1
-# TODO: Song: Export Song to CCLI
-# TODO: Song: Export Song to OpenSong
-# TODO: Song: Import ChangingSong
-# TODO: Song: Export ChangingSong
-
-class Song(object):
- """Handling song properties and methods
-
- handles all conversions between various input and output formats
-
- CCLI:
- from_ccli_text_file
- to_ccli_text_file
- from_ccli_text_buffer
- to_ccli_text_buffer
-
- presentation (screen):
- get_preview_slide
- get_render_slide
-
- openlp1:
- from_openlp1_lyrics_buffer
- to_openlp1_lyrics_buffer
- set_author_list
- get_author_list
-
- editing and openlp2:
- set_*
- get_*
- """
-
- def __init__(self, songid = 0):
- """Initialize song object
-
- songid -- database id for this song
- title -- title of the song
- search_title -- title without punctuation chars
- author_list -- list of authors
- song_cclino -- CCLI number for this song
- copyright -- copyright string
- show_title -- 0: no show, 1: show
- show_author_list -- 0: no show, 1: show
- show_copyright -- 0: no show, 1: show
- show_song_cclino -- 0: no show, 1: show
- theme_name -- name of theme or blank
- category_array -- list of user defined properties (hymn, gospel)
- song_book -- name of originating book
- song_number -- number of the song, related to a songbook
- comments -- free comment
- verse_order -- presentation order of the slides
- lyrics -- text format
- search_lyrics -- lowercase lyrics without punctuation
- """
- self.songid = songid
- self._reset()
-
- def _reset(self):
- """Reset all song attributes"""
- self.slideList = []
- self.set_title(u'BlankSong')
- self.author_list = None
- self.song_cclino = ""
- self.copyright = ""
- self.show_author_list = 1
- self.show_copyright = 1
- self.show_song_cclino = 1
- self.show_title = 1
- self.theme_name = ""
- self.category_array = None
- self.song_book = ""
- self.song_number = ""
- self.comments = ""
- self.verse_order = ""
- self.set_lyrics(u'')
- return
-
- def _remove_punctuation(self, title):
- """Remove the puntuation chars from title
-
- chars are: .,:;!?&%#/\@`$'|"^~*-
- """
- punctuation = ".,:;!?&%#'\"/\\@`$|^~*-"
- string = title
- for char in punctuation:
- string = string.replace(char, '')
- return string
-
- def set_title(self, title):
- """Set the song title
-
- title (string)
- raises SongTitleError if the title is empty
- raises SongTitleError if the seach_title is empty
- """
- self.title = title.strip()
- self.search_title = self._remove_punctuation(title).strip()
- if len(self.title) < 1:
- raise SongTitleError(u'The title is empty')
- if len(self.search_title) < 1:
- raise SongTitleError(u'The searchable title is empty')
-
- def from_ccli_text_buffer(self, textList):
- """
- Create song from a list of texts (strings) - CCLI text format expected
-
- textList (list of strings) -- the song
- """
- self._reset()
- # extract the following fields
- # - name
- # - author
- # - CCLI no
- sName = ""
- sAuthor = ""
- sCopyright = ""
- sCcli = ""
- lastpart = 0
- lineCount = 0
- metMisc = False
- lyrics = []
- for line in textList:
- lineCount += 1
- if lastpart > 0:
- lastpart += 1
- if lastpart == 2:
- sCopyright = line[1:].strip()
- if lastpart == 3:
- sAuthor = line
- elif line.startswith(u'CCLI Song'):
- sCcli = line[13:].strip()
- lastpart = 1
- else:
- if metMisc:
- metMisc = False
- if line.upper().startswith(u'(BRIDGE)'):
- lyrics.append(u'# Bridge')
- # otherwise unknown misc keyword
- elif line.startswith(u'Misc'):
- metMisc = True
- elif line.startswith(u'Verse') or line.startswith(u'Chorus'):
- lyrics.append(u'# %s' % line)
- else:
- # should we remove multiple blank lines?
- if lineCount == 1:
- sName = line
- else:
- lyrics.append(line)
- # split on known separators
- lst = sAuthor.split(u'/')
- if len(lst) < 2:
- lst = sAuthor.split(u'|')
- author_list = u', '.join(lst)
- self.set_title(sName)
- self.set_author_list(author_list)
- self.copyright = sCopyright
- self.ccli_number = sCcli
- self.set_lyrics(lyrics)
-
- def from_ccli_text_file(self, textFileName):
- """
- Create song from a list of texts read from given file
- textFileName -- path to text file
- """
- ccli_file = None
- try:
- ccli_file = open(textFileName, 'r')
- lines = [orgline.rstrip() for orgline in ccli_file]
- self.from_ccli_text_buffer(lines)
- except IOError:
- log.exception(u'Failed to load CCLI text file')
- finally:
- if ccli_file:
- ccli_file.close()
-
- def _assure_string(self, string_in):
- """Force a string is returned"""
- if string_in is None:
- string_out = ""
- else:
- string_out = unicode(string_in)
- return string_out
-
- def _split_to_list(self, aString):
- """Split a string into a list - comma separated"""
- if aString:
- list = aString.split(u',')
- res = [item.strip() for item in list]
- return res
-
- def _list_to_string(self, strOrList):
- """Force a possibly list into a string"""
- if isinstance(strOrList, basestring):
- lst = self._split_to_list(strOrList)
- elif isinstance(strOrList, ListType):
- lst = strOrList
- elif strOrList is None:
- lst = []
- else:
- raise SongTypeError(u'Variable not String or List')
- string = u', '.join(lst)
- return string
-
- def get_copyright(self):
- """Return copyright info string"""
- return self._assure_string(self.copyright)
-
- def get_ccli_number(self):
- """Return the songCclino"""
- return self._assure_string(self.ccli_number)
-
- def get_theme_name(self):
- """Return the theme name for the song"""
- return self._assure_string(self.theme_name)
-
- def get_song_book(self):
- """Return the song_book (string)"""
- return self._assure_string(self.song_book)
-
- def get_song_number(self):
- """Return the song_number (string)"""
- return self._assure_string(self.song_number)
-
- def get_comments(self):
- """Return the comments (string)"""
- return self._assure_string(self.comments)
-
- def get_verse_order(self):
- """Get the verseOrder (string) - preferably space delimited"""
- return self._assure_string(self.verse_order)
-
- def get_author_list(self, asOneString = True):
- """Return the list of authors as a string
-
- ``asOneString``
- If ``True``, returns 'John Newton, A Parker'. If ``False``, returns
- [u'John Newton', u'A Parker']
- """
- if asOneString:
- res = self._assure_string(self.author_list)
- else:
- res = self._split_to_list(self.author_list)
- return res
-
- def set_author_list(self, author_list):
- """Set the author_list
-
- ``author_list``
- a string or list of strings
- """
- if author_list is None:
- self.author_list = None
- else:
- self.author_list = self._list_to_string(author_list)
-
- def get_category_array(self, asOneString = True):
- """Return the list of categories as a string
-
- ``asOneString``
- If ``True``, returns 'Hymn, Gospel'. If ``False``, returns
- [u'Hymn', u'Gospel']
- """
- if asOneString:
- res = self._assure_string(self.category_array)
- else:
- res = self._split_to_list(self.category_array)
- return res
-
- def set_category_array(self, category_array):
- """Set the category_array
-
- category_array -- a string or list of strings
- """
- if category_array is None:
- self.category_array = None
- else:
- self.category_array = self._list_to_string(category_array)
-
- def set_lyrics(self, lyrics):
- """Set the lyrics as a list of strings"""
- self.lyrics = lyrics
- self._parse_lyrics()
-
- def _parse_lyrics(self):
- """Parse lyrics into the slidelist"""
- # TODO: check font formatting
- self.slideList = []
- tmpSlide = []
- metContent = False
- for lyric in self.lyrics:
- if lyric:
- metContent = True
- tmpSlide.append(lyric)
- else:
- if metContent:
- metContent = False
- self.slideList.append(tmpSlide)
- tmpSlide = []
- if tmpSlide:
- self.slideList.append(tmpSlide)
-
- def get_preview_slide(self, slideNumber):
- """Return the preview text for specified slide number
-
- slideNumber -- 0: all slides, 1..n: specific slide
- a list of strings are returned
- """
- num = len(self.slideList)
- if num < 1:
- raise SongSlideError(u'No slides in this song')
- elif slideNumber > num:
- raise SongSlideError(u'Slide number too high')
- if slideNumber > 0:
- # return this slide
- res = self.slideList[slideNumber-1]
- # find theme in this slide
- else:
- res = []
- for i in range(num):
- if i > 0:
- res.append(u'')
- res.extend()
- # remove formattingincluding themes
- return res
-
- def get_render_slide(self, slideNumber):
- """Return the slide to be rendered including the additional
- properties
-
- slideNumber -- 1 .. numberOfSlides
-
- Returns a list as:
- [theme_name (string),
- title (string),
- authorlist (string),
- copyright (string),
- cclino (string),
- lyric-part as a list of strings]
- """
- num = len(self.slideList)
- if num < 1:
- raise SongSlideError(u'No slides in this song')
- elif slideNumber > num:
- raise SongSlideError(u'Slide number too high')
- res = []
- if self.show_title:
- title = self.title
- else:
- title = ""
- if self.show_author_list:
- author = self.get_author_list(True)
- else:
- author = ""
- if self.show_copyright:
- cpright = self.get_copyright()
- else:
- cpright = ""
- if self.show_ccli_number:
- ccli = self.get_ccli_number()
- else:
- ccli = ""
- theme_name = self.get_theme_name()
- # examine the slide for a theme
- res.append(theme_name)
- res.append(title)
- res.append(author)
- res.append(cpright)
- res.append(ccli)
- # append the correct slide
- return res
-
-__all__ = ['SongException', 'SongTitleError', 'SongSlideError', 'SongTypeError',
- 'SongFeatureError', 'Song']
Follow ups