Various tidy-ups:

* themeform: spelling
* easyslidesimport: old code, comment copied from elsewhere
* importer: clarify docstring
* zionworximport: module constant, variable names

bzr-revno: 2023
This commit is contained in:
Samuel Findlay 2012-07-08 21:37:05 +02:00 committed by Andreas Preikschat
commit 6d9cc62ab4
4 changed files with 8 additions and 14 deletions

View File

@ -226,7 +226,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
def onCurrentIdChanged(self, pageId):
"""
Detects Page changes and updates as approprate.
Detects Page changes and updates as appropriate.
"""
enabled = self.page(pageId) == self.areaPositionPage
self.setOption(QtGui.QWizard.HaveCustomButton1, enabled)

View File

@ -48,15 +48,8 @@ class EasySlidesImport(SongImport):
Initialise the class.
"""
SongImport.__init__(self, manager, **kwargs)
self.commit = True
def doImport(self):
"""
Import either each of the files in self.importSources - each element of
which can be either a single opensong file, or a zipfile containing
multiple opensong files. If `self.commit` is set False, the
import will not be committed to the database (useful for test scripts).
"""
log.info(u'Importing EasySlides XML file %s', self.importSource)
parser = etree.XMLParser(remove_blank_text=True)
parsed_file = etree.parse(self.importSource, parser)

View File

@ -109,6 +109,7 @@ class SongFormat(object):
``u'canDisable'``
Whether song format importer is disablable.
If ``True``, then ``u'disabledLabelText'`` must also be defined.
``u'availability'``
Whether song format importer is available.

View File

@ -37,6 +37,9 @@ from openlp.plugins.songs.lib.songimport import SongImport
log = logging.getLogger(__name__)
# Used to strip control chars (except 10=LF, 13=CR)
CONTROL_CHARS_MAP = dict.fromkeys(range(10) + [11, 12] + range(14,32) + [127])
class ZionWorxImport(SongImport):
"""
The :class:`ZionWorxImport` class provides the ability to import songs
@ -78,13 +81,10 @@ class ZionWorxImport(SongImport):
"""
Receive a CSV file (from a ZionWorx database dump) to import.
"""
# Used to strip control chars (10=LF, 13=CR, 127=DEL)
self.control_chars_map = dict.fromkeys(
range(10) + [11, 12] + range(14,32) + [127])
with open(self.importSource, 'rb') as songs_file:
fieldnames = [u'SongNum', u'Title1', u'Title2', u'Lyrics',
field_names = [u'SongNum', u'Title1', u'Title2', u'Lyrics',
u'Writer', u'Copyright', u'Keywords', u'DefaultStyle']
songs_reader = csv.DictReader(songs_file, fieldnames)
songs_reader = csv.DictReader(songs_file, field_names)
try:
records = list(songs_reader)
except csv.Error, e:
@ -140,4 +140,4 @@ class ZionWorxImport(SongImport):
"""
# This encoding choice seems OK. ZionWorx has no option for setting the
# encoding for its songs, so we assume encoding is always the same.
return unicode(str, u'cp1252').translate(self.control_chars_map)
return unicode(str, u'cp1252').translate(CONTROL_CHARS_MAP)