forked from openlp/openlp
Import and line ending fixes
This commit is contained in:
parent
3f5ac846f6
commit
cbc93259cb
@ -27,7 +27,6 @@ from PyQt4 import QtCore, QtGui
|
|||||||
|
|
||||||
from openlp.core.lib import SettingsTab, str_to_bool
|
from openlp.core.lib import SettingsTab, str_to_bool
|
||||||
from openlp.plugins.alerts.lib.models import AlertItem
|
from openlp.plugins.alerts.lib.models import AlertItem
|
||||||
from openlp.plugins.alerts.lib import alertsmanager
|
|
||||||
|
|
||||||
class AlertsTab(SettingsTab):
|
class AlertsTab(SettingsTab):
|
||||||
"""
|
"""
|
||||||
|
@ -29,10 +29,11 @@
|
|||||||
# http://www.oooforum.org/forum/viewtopic.phtml?t=14409
|
# http://www.oooforum.org/forum/viewtopic.phtml?t=14409
|
||||||
# http://wiki.services.openoffice.org/wiki/Python
|
# http://wiki.services.openoffice.org/wiki/Python
|
||||||
|
|
||||||
import re
|
|
||||||
import os
|
import os
|
||||||
import time
|
import re
|
||||||
|
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
from songimport import SongImport
|
from songimport import SongImport
|
||||||
|
|
||||||
if os.name == u'nt':
|
if os.name == u'nt':
|
||||||
@ -69,9 +70,9 @@ class SofImport(object):
|
|||||||
Initialise the class. Requires a songmanager class which is passed
|
Initialise the class. Requires a songmanager class which is passed
|
||||||
to SongImport for writing song to disk
|
to SongImport for writing song to disk
|
||||||
"""
|
"""
|
||||||
self.song = None
|
self.song = None
|
||||||
self.manager = songmanager
|
self.manager = songmanager
|
||||||
self.process_started = False
|
self.process_started = False
|
||||||
|
|
||||||
def import_sof(self, filename):
|
def import_sof(self, filename):
|
||||||
self.start_ooo()
|
self.start_ooo()
|
||||||
@ -86,7 +87,7 @@ class SofImport(object):
|
|||||||
"""
|
"""
|
||||||
if os.name == u'nt':
|
if os.name == u'nt':
|
||||||
self.start_ooo_process()
|
self.start_ooo_process()
|
||||||
self.desktop = self.manager.createInstance(u'com.sun.star.frame.Desktop')
|
self.desktop = self.manager.createInstance(u'com.sun.star.frame.Desktop')
|
||||||
else:
|
else:
|
||||||
context = uno.getComponentContext()
|
context = uno.getComponentContext()
|
||||||
resolver = context.ServiceManager.createInstanceWithContext(
|
resolver = context.ServiceManager.createInstanceWithContext(
|
||||||
@ -110,10 +111,10 @@ class SofImport(object):
|
|||||||
if os.name == u'nt':
|
if os.name == u'nt':
|
||||||
self.manager = Dispatch(u'com.sun.star.ServiceManager')
|
self.manager = Dispatch(u'com.sun.star.ServiceManager')
|
||||||
self.manager._FlagAsMethod(u'Bridge_GetStruct')
|
self.manager._FlagAsMethod(u'Bridge_GetStruct')
|
||||||
self.manager._FlagAsMethod(u'Bridge_GetValueObject')
|
self.manager._FlagAsMethod(u'Bridge_GetValueObject')
|
||||||
else:
|
else:
|
||||||
cmd = u'openoffice.org -nologo -norestore -minimized -invisible ' \
|
cmd = u'openoffice.org -nologo -norestore -minimized -invisible ' \
|
||||||
+ u'-nofirststartwizard ' \
|
+ u'-nofirststartwizard ' \
|
||||||
+ '-accept="socket,host=localhost,port=2002;urp;"'
|
+ '-accept="socket,host=localhost,port=2002;urp;"'
|
||||||
process = QtCore.QProcess()
|
process = QtCore.QProcess()
|
||||||
process.startDetached(cmd)
|
process.startDetached(cmd)
|
||||||
@ -283,21 +284,21 @@ class SofImport(object):
|
|||||||
"""
|
"""
|
||||||
Add a song number, store as alternate title. Also use the song
|
Add a song number, store as alternate title. Also use the song
|
||||||
number to work out which songbook we're in
|
number to work out which songbook we're in
|
||||||
"""
|
"""
|
||||||
self.song.set_song_number(song_no)
|
self.song.set_song_number(song_no)
|
||||||
self.song.set_alternate_title(song_no + u'.')
|
self.song.set_alternate_title(song_no + u'.')
|
||||||
if int(song_no) <= 640:
|
if int(song_no) <= 640:
|
||||||
self.song.set_song_book(u'Songs of Fellowship 1',
|
self.song.set_song_book(u'Songs of Fellowship 1',
|
||||||
u'Kingsway Publications')
|
u'Kingsway Publications')
|
||||||
elif int(song_no) <= 1150:
|
elif int(song_no) <= 1150:
|
||||||
self.song.set_song_book(u'Songs of Fellowship 2',
|
self.song.set_song_book(u'Songs of Fellowship 2',
|
||||||
u'Kingsway Publications')
|
u'Kingsway Publications')
|
||||||
elif int(song_no) <= 1690:
|
elif int(song_no) <= 1690:
|
||||||
self.song.set_song_book(u'Songs of Fellowship 3',
|
self.song.set_song_book(u'Songs of Fellowship 3',
|
||||||
u'Kingsway Publications')
|
u'Kingsway Publications')
|
||||||
else:
|
else:
|
||||||
self.song.set_song_book(u'Songs of Fellowship 4',
|
self.song.set_song_book(u'Songs of Fellowship 4',
|
||||||
u'Kingsway Publications')
|
u'Kingsway Publications')
|
||||||
|
|
||||||
def add_title(self, text):
|
def add_title(self, text):
|
||||||
"""
|
"""
|
||||||
@ -328,9 +329,9 @@ class SofImport(object):
|
|||||||
+ authors[i + 1].strip().split(u' ')[-1]
|
+ authors[i + 1].strip().split(u' ')[-1]
|
||||||
if author2.endswith(u'.'):
|
if author2.endswith(u'.'):
|
||||||
author2 = author2[:-1]
|
author2 = author2[:-1]
|
||||||
if author2:
|
if author2:
|
||||||
self.song.add_author(author2)
|
self.song.add_author(author2)
|
||||||
|
|
||||||
def add_verse_line(self, text):
|
def add_verse_line(self, text):
|
||||||
"""
|
"""
|
||||||
Add a line to the current verse. If the formatting has changed and
|
Add a line to the current verse. If the formatting has changed and
|
||||||
@ -349,36 +350,36 @@ class SofImport(object):
|
|||||||
Verse is finished, store it. Note in book 1+2, some songs are formatted
|
Verse is finished, store it. Note in book 1+2, some songs are formatted
|
||||||
incorrectly. Here we try and split songs with missing line breaks into
|
incorrectly. Here we try and split songs with missing line breaks into
|
||||||
the correct number of verses.
|
the correct number of verses.
|
||||||
"""
|
"""
|
||||||
if self.currentverse.strip() == u'':
|
if self.currentverse.strip() == u'':
|
||||||
return
|
return
|
||||||
if self.is_chorus:
|
if self.is_chorus:
|
||||||
versetag = u'C'
|
versetag = u'C'
|
||||||
splitat = None
|
splitat = None
|
||||||
else:
|
else:
|
||||||
versetag = u'V'
|
versetag = u'V'
|
||||||
splitat = self.verse_splits(self.song.get_song_number())
|
splitat = self.verse_splits(self.song.get_song_number())
|
||||||
if splitat:
|
if splitat:
|
||||||
ln = 0
|
ln = 0
|
||||||
verse = u''
|
verse = u''
|
||||||
for line in self.currentverse.split(u'\n'):
|
for line in self.currentverse.split(u'\n'):
|
||||||
ln += 1
|
ln += 1
|
||||||
if line == u'' or ln > splitat:
|
if line == u'' or ln > splitat:
|
||||||
self.song.add_verse(verse, versetag)
|
self.song.add_verse(verse, versetag)
|
||||||
ln = 0
|
ln = 0
|
||||||
if line:
|
if line:
|
||||||
verse = line + u'\n'
|
verse = line + u'\n'
|
||||||
else:
|
else:
|
||||||
verse = u''
|
verse = u''
|
||||||
else:
|
else:
|
||||||
verse += line + u'\n'
|
verse += line + u'\n'
|
||||||
if verse:
|
if verse:
|
||||||
self.song.add_verse(verse, versetag)
|
self.song.add_verse(verse, versetag)
|
||||||
else:
|
else:
|
||||||
self.song.add_verse(self.currentverse, versetag)
|
self.song.add_verse(self.currentverse, versetag)
|
||||||
self.currentverse = u''
|
self.currentverse = u''
|
||||||
self.is_chorus = False
|
self.is_chorus = False
|
||||||
|
|
||||||
def tidy_text(self, text):
|
def tidy_text(self, text):
|
||||||
"""
|
"""
|
||||||
Get rid of some dodgy unicode and formatting characters we're not
|
Get rid of some dodgy unicode and formatting characters we're not
|
||||||
|
Loading…
Reference in New Issue
Block a user