forked from openlp/openlp
Remove static methods and re-work code to avoid creation of additional SongImport's.
This commit is contained in:
parent
b522247094
commit
b4e8880671
@ -192,9 +192,7 @@ class OooImport(SongImport):
|
|||||||
if slidetext.strip() == u'':
|
if slidetext.strip() == u'':
|
||||||
slidetext = u'\f'
|
slidetext = u'\f'
|
||||||
text += slidetext
|
text += slidetext
|
||||||
songs = SongImport.process_songs_text(self.manager, text)
|
self.process_songs_text(text)
|
||||||
for song in songs:
|
|
||||||
song.finish()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def process_doc(self):
|
def process_doc(self):
|
||||||
@ -216,6 +214,16 @@ class OooImport(SongImport):
|
|||||||
if textportion.BreakType in (PAGE_AFTER, PAGE_BOTH):
|
if textportion.BreakType in (PAGE_AFTER, PAGE_BOTH):
|
||||||
paratext += u'\f'
|
paratext += u'\f'
|
||||||
text += paratext + u'\n'
|
text += paratext + u'\n'
|
||||||
songs = SongImport.process_songs_text(self.manager, text)
|
self.process_songs_text(text)
|
||||||
for song in songs:
|
|
||||||
song.finish()
|
def process_songs_text(self, text):
|
||||||
|
songtexts = self.tidy_text(text).split(u'\f')
|
||||||
|
self.set_defaults()
|
||||||
|
for songtext in songtexts:
|
||||||
|
if songtext.strip():
|
||||||
|
self.process_song_text(songtext.strip())
|
||||||
|
if self.check_complete():
|
||||||
|
self.finish()
|
||||||
|
self.set_defaults()
|
||||||
|
if self.check_complete():
|
||||||
|
self.finish()
|
||||||
|
@ -183,7 +183,7 @@ class SofImport(OooImport):
|
|||||||
into line
|
into line
|
||||||
"""
|
"""
|
||||||
text = textportion.getString()
|
text = textportion.getString()
|
||||||
text = SongImport.tidy_text(text)
|
text = self.tidy_text(text)
|
||||||
if text.strip() == u'':
|
if text.strip() == u'':
|
||||||
return text
|
return text
|
||||||
if textportion.CharWeight == BOLD:
|
if textportion.CharWeight == BOLD:
|
||||||
@ -299,8 +299,15 @@ class SofImport(OooImport):
|
|||||||
verse += line + u'\n'
|
verse += line + u'\n'
|
||||||
if verse:
|
if verse:
|
||||||
self.song.add_verse(verse, versetag)
|
self.song.add_verse(verse, versetag)
|
||||||
|
if not self.is_chorus and \
|
||||||
|
u'C1' in self.verse_order_list_generated:
|
||||||
|
self.verse_order_list_generated.append(u'C1')
|
||||||
|
self.verse_order_list_generated_useful = True
|
||||||
else:
|
else:
|
||||||
self.song.add_verse(self.currentverse, versetag)
|
self.song.add_verse(self.currentverse, versetag)
|
||||||
|
if not self.is_chorus and u'C1' in self.verse_order_list_generated:
|
||||||
|
self.verse_order_list_generated.append(u'C1')
|
||||||
|
self.verse_order_list_generated_useful = True
|
||||||
self.currentverse = u''
|
self.currentverse = u''
|
||||||
self.is_chorus = False
|
self.is_chorus = False
|
||||||
|
|
||||||
|
@ -55,7 +55,6 @@ class SongImport(QtCore.QObject):
|
|||||||
"""
|
"""
|
||||||
self.manager = manager
|
self.manager = manager
|
||||||
QtCore.QObject.__init__(self)
|
QtCore.QObject.__init__(self)
|
||||||
if kwargs:
|
|
||||||
if kwargs.has_key(u'filename'):
|
if kwargs.has_key(u'filename'):
|
||||||
self.import_source = kwargs[u'filename']
|
self.import_source = kwargs[u'filename']
|
||||||
elif kwargs.has_key(u'filenames'):
|
elif kwargs.has_key(u'filenames'):
|
||||||
@ -104,23 +103,7 @@ class SongImport(QtCore.QObject):
|
|||||||
def register(self, import_wizard):
|
def register(self, import_wizard):
|
||||||
self.import_wizard = import_wizard
|
self.import_wizard = import_wizard
|
||||||
|
|
||||||
@staticmethod
|
def tidy_text(self, text):
|
||||||
def process_songs_text(manager, text):
|
|
||||||
songs = []
|
|
||||||
songtexts = SongImport.tidy_text(text).split(u'\f')
|
|
||||||
song = SongImport(manager)
|
|
||||||
for songtext in songtexts:
|
|
||||||
if songtext.strip():
|
|
||||||
song.process_song_text(songtext.strip())
|
|
||||||
if song.check_complete():
|
|
||||||
songs.append(song)
|
|
||||||
song = SongImport(manager)
|
|
||||||
if song.check_complete():
|
|
||||||
songs.append(song)
|
|
||||||
return songs
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def tidy_text(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
|
||||||
interested in. Some can be converted to ascii.
|
interested in. Some can be converted to ascii.
|
||||||
|
Loading…
Reference in New Issue
Block a user