forked from openlp/openlp
Cleanups
This commit is contained in:
parent
23859bb241
commit
5fe753c833
@ -38,62 +38,47 @@ log = logging.getLogger(__name__)
|
|||||||
# TODO make external and configurable in alpha 4 via a settings dialog
|
# TODO make external and configurable in alpha 4 via a settings dialog
|
||||||
html_expands = []
|
html_expands = []
|
||||||
|
|
||||||
html_expands.append({u'desc':u'Red', u'start tag':u'{r}', \
|
html_expands.append({u'desc':u'Red', u'start tag':u'{r}',
|
||||||
u'start html':u'<span style="-webkit-text-fill-color:red">', \
|
u'start html':u'<span style="-webkit-text-fill-color:red">',
|
||||||
u'end tag':u'{/r}', u'end html':u'</span>', \
|
u'end tag':u'{/r}', u'end html':u'</span>', u'protected':False})
|
||||||
u'protected':False})
|
html_expands.append({u'desc':u'Black', u'start tag':u'{b}',
|
||||||
html_expands.append({u'desc':u'Black', u'start tag':u'{b}', \
|
u'start html':u'<span style="-webkit-text-fill-color:black">',
|
||||||
u'start html':u'<span style="-webkit-text-fill-color:black">', \
|
u'end tag':u'{/b}', u'end html':u'</span>', u'protected':False})
|
||||||
u'end tag':u'{/b}', u'end html':u'</span>', \
|
html_expands.append({u'desc':u'Blue', u'start tag':u'{bl}',
|
||||||
u'protected':False})
|
u'start html':u'<span style="-webkit-text-fill-color:blue">',
|
||||||
html_expands.append({u'desc':u'Blue', u'start tag':u'{bl}', \
|
u'end tag':u'{/bl}', u'end html':u'</span>', u'protected':False})
|
||||||
u'start html':u'<span style="-webkit-text-fill-color:blue">', \
|
html_expands.append({u'desc':u'Yellow', u'start tag':u'{y}',
|
||||||
u'end tag':u'{/bl}', u'end html':u'</span>', \
|
u'start html':u'<span style="-webkit-text-fill-color:yellow">',
|
||||||
u'protected':False})
|
u'end tag':u'{/y}', u'end html':u'</span>', u'protected':False})
|
||||||
html_expands.append({u'desc':u'Yellow', u'start tag':u'{y}', \
|
html_expands.append({u'desc':u'Green', u'start tag':u'{g}',
|
||||||
u'start html':u'<span style="-webkit-text-fill-color:yellow">', \
|
u'start html':u'<span style="-webkit-text-fill-color:green">',
|
||||||
u'end tag':u'{/y}', u'end html':u'</span>', \
|
u'end tag':u'{/g}', u'end html':u'</span>', u'protected':False})
|
||||||
u'protected':False})
|
html_expands.append({u'desc':u'Pink', u'start tag':u'{pk}',
|
||||||
html_expands.append({u'desc':u'Green', u'start tag':u'{g}', \
|
u'start html':u'<span style="-webkit-text-fill-color:#CC33CC">',
|
||||||
u'start html':u'<span style="-webkit-text-fill-color:green">', \
|
u'end tag':u'{/pk}', u'end html':u'</span>', u'protected':False})
|
||||||
u'end tag':u'{/g}', u'end html':u'</span>', \
|
html_expands.append({u'desc':u'Orange', u'start tag':u'{o}',
|
||||||
u'protected':False})
|
u'start html':u'<span style="-webkit-text-fill-color:#CC0033">',
|
||||||
html_expands.append({u'desc':u'Pink', u'start tag':u'{pk}', \
|
u'end tag':u'{/o}', u'end html':u'</span>', u'protected':False})
|
||||||
u'start html':u'<span style="-webkit-text-fill-color:#CC33CC">', \
|
html_expands.append({u'desc':u'Purple', u'start tag':u'{pp}',
|
||||||
u'end tag':u'{/pk}', u'end html':u'</span>', \
|
u'start html':u'<span style="-webkit-text-fill-color:#9900FF">',
|
||||||
u'protected':False})
|
u'end tag':u'{/pp}', u'end html':u'</span>', u'protected':False})
|
||||||
html_expands.append({u'desc':u'Orange', u'start tag':u'{o}', \
|
html_expands.append({u'desc':u'White', u'start tag':u'{w}',
|
||||||
u'start html':u'<span style="-webkit-text-fill-color:#CC0033">', \
|
u'start html':u'<span style="-webkit-text-fill-color:white">',
|
||||||
u'end tag':u'{/o}', u'end html':u'</span>', \
|
u'end tag':u'{/w}', u'end html':u'</span>', u'protected':False})
|
||||||
u'protected':False})
|
html_expands.append({u'desc':u'Superscript', u'start tag':u'{su}',
|
||||||
html_expands.append({u'desc':u'Purple', u'start tag':u'{pp}', \
|
u'start html':u'<sup>', u'end tag':u'{/su}', u'end html':u'</sup>',
|
||||||
u'start html':u'<span style="-webkit-text-fill-color:#9900FF">', \
|
|
||||||
u'end tag':u'{/pp}', u'end html':u'</span>', \
|
|
||||||
u'protected':False})
|
|
||||||
html_expands.append({u'desc':u'White', u'start tag':u'{w}', \
|
|
||||||
u'start html':u'<span style="-webkit-text-fill-color:white">', \
|
|
||||||
u'end tag':u'{/w}', u'end html':u'</span>', \
|
|
||||||
u'protected':False})
|
|
||||||
html_expands.append({u'desc':u'Superscript', u'start tag':u'{su}', \
|
|
||||||
u'start html':u'<sup>', \
|
|
||||||
u'end tag':u'{/su}', u'end html':u'</sup>', \
|
|
||||||
u'protected':True})
|
u'protected':True})
|
||||||
html_expands.append({u'desc':u'Subscript', u'start tag':u'{sb}', \
|
html_expands.append({u'desc':u'Subscript', u'start tag':u'{sb}',
|
||||||
u'start html':u'<sub>', \
|
u'start html':u'<sub>', u'end tag':u'{/sb}', u'end html':u'</sub>',
|
||||||
u'end tag':u'{/sb}', u'end html':u'</sub>', \
|
|
||||||
u'protected':True})
|
u'protected':True})
|
||||||
html_expands.append({u'desc':u'Paragraph', u'start tag':u'{p}', \
|
html_expands.append({u'desc':u'Paragraph', u'start tag':u'{p}',
|
||||||
u'start html':u'<p>', \
|
u'start html':u'<p>', u'end tag':u'{/p}', u'end html':u'</p>',
|
||||||
u'end tag':u'{/p}', u'end html':u'</p>', \
|
|
||||||
u'protected':True})
|
u'protected':True})
|
||||||
html_expands.append({u'desc':u'Bold', u'start tag':u'{st}', \
|
html_expands.append({u'desc':u'Bold', u'start tag':u'{st}',
|
||||||
u'start html':u'<strong>', \
|
u'start html':u'<strong>', u'end tag':u'{/st}', u'end html':u'</strong>',
|
||||||
u'end tag':u'{/st}', \
|
|
||||||
u'end html':u'</strong>', \
|
|
||||||
u'protected':True})
|
u'protected':True})
|
||||||
html_expands.append({u'desc':u'Italics', u'start tag':u'{it}', \
|
html_expands.append({u'desc':u'Italics', u'start tag':u'{it}',
|
||||||
u'start html':u'<em>', \
|
u'start html':u'<em>', u'end tag':u'{/it}', u'end html':u'</em>',
|
||||||
u'end tag':u'{/it}', u'end html':u'</em>', \
|
|
||||||
u'protected':True})
|
u'protected':True})
|
||||||
|
|
||||||
def translate(context, text, comment=None):
|
def translate(context, text, comment=None):
|
||||||
|
@ -678,7 +678,8 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.dual_search_results[count].text)
|
self.dual_search_results[count].text)
|
||||||
}
|
}
|
||||||
bible_text = u' %s %d:%d (%s, %s)' % (verse.book.name,
|
bible_text = u' %s %d:%d (%s, %s)' % (verse.book.name,
|
||||||
verse.chapter, verse.verse, version.value, dual_version.value)
|
verse.chapter, verse.verse, version.value,
|
||||||
|
dual_version.value)
|
||||||
else:
|
else:
|
||||||
vdict = {
|
vdict = {
|
||||||
'book': QtCore.QVariant(verse.book.name),
|
'book': QtCore.QVariant(verse.book.name),
|
||||||
|
@ -81,14 +81,15 @@ class CCLIFileImport(SongImport):
|
|||||||
lines = infile.readlines()
|
lines = infile.readlines()
|
||||||
ext = os.path.splitext(filename)[1]
|
ext = os.path.splitext(filename)[1]
|
||||||
if ext.lower() == ".usr":
|
if ext.lower() == ".usr":
|
||||||
log.info(u'SongSelect .usr format file found %s: ' , filename)
|
log.info(u'SongSelect .usr format file found %s: ',
|
||||||
|
filename)
|
||||||
self.do_import_usr_file(lines)
|
self.do_import_usr_file(lines)
|
||||||
elif ext.lower() == ".txt":
|
elif ext.lower() == ".txt":
|
||||||
log.info(u'SongSelect .txt format file found %s: ', filename)
|
log.info(u'SongSelect .txt format file found %s: ',
|
||||||
|
filename)
|
||||||
self.do_import_txt_file(lines)
|
self.do_import_txt_file(lines)
|
||||||
else:
|
else:
|
||||||
log.info(u'Extension %s is not valid', filename)
|
log.info(u'Extension %s is not valid', filename)
|
||||||
pass
|
|
||||||
song_count += 1
|
song_count += 1
|
||||||
if self.stop_import_flag:
|
if self.stop_import_flag:
|
||||||
return False
|
return False
|
||||||
@ -175,7 +176,7 @@ class CCLIFileImport(SongImport):
|
|||||||
verse_text = unicode(words_list[counter])
|
verse_text = unicode(words_list[counter])
|
||||||
verse_text = verse_text.replace("/n", "\n")
|
verse_text = verse_text.replace("/n", "\n")
|
||||||
if len(verse_text) > 0:
|
if len(verse_text) > 0:
|
||||||
self.add_verse(verse_text, verse_type);
|
self.add_verse(verse_text, verse_type)
|
||||||
#Handle multiple authors
|
#Handle multiple authors
|
||||||
author_list = song_author.split(u'/')
|
author_list = song_author.split(u'/')
|
||||||
if len(author_list) < 2:
|
if len(author_list) < 2:
|
||||||
@ -238,12 +239,12 @@ class CCLIFileImport(SongImport):
|
|||||||
line_number = 0
|
line_number = 0
|
||||||
verse_text = u''
|
verse_text = u''
|
||||||
song_comments = u''
|
song_comments = u''
|
||||||
song_copyright = u'';
|
song_copyright = u''
|
||||||
verse_start = False
|
verse_start = False
|
||||||
for line in textList:
|
for line in textList:
|
||||||
clean_line = line.strip()
|
clean_line = line.strip()
|
||||||
if not clean_line:
|
if not clean_line:
|
||||||
if line_number==0:
|
if line_number == 0:
|
||||||
continue
|
continue
|
||||||
elif verse_start:
|
elif verse_start:
|
||||||
if verse_text:
|
if verse_text:
|
||||||
@ -252,11 +253,11 @@ class CCLIFileImport(SongImport):
|
|||||||
verse_start = False
|
verse_start = False
|
||||||
else:
|
else:
|
||||||
#line_number=0, song title
|
#line_number=0, song title
|
||||||
if line_number==0:
|
if line_number == 0:
|
||||||
song_name = clean_line
|
song_name = clean_line
|
||||||
line_number += 1
|
line_number += 1
|
||||||
#line_number=1, verses
|
#line_number=1, verses
|
||||||
elif line_number==1:
|
elif line_number == 1:
|
||||||
#line_number=1, ccli number, first line after verses
|
#line_number=1, ccli number, first line after verses
|
||||||
if clean_line.startswith(u'CCLI'):
|
if clean_line.startswith(u'CCLI'):
|
||||||
line_number += 1
|
line_number += 1
|
||||||
@ -285,15 +286,16 @@ class CCLIFileImport(SongImport):
|
|||||||
verse_text = verse_text + line
|
verse_text = verse_text + line
|
||||||
else:
|
else:
|
||||||
#line_number=2, copyright
|
#line_number=2, copyright
|
||||||
if line_number==2:
|
if line_number == 2:
|
||||||
line_number += 1
|
line_number += 1
|
||||||
song_copyright = clean_line
|
song_copyright = clean_line
|
||||||
#n=3, authors
|
#n=3, authors
|
||||||
elif line_number==3:
|
elif line_number == 3:
|
||||||
line_number += 1
|
line_number += 1
|
||||||
song_author = clean_line
|
song_author = clean_line
|
||||||
#line_number=4, comments lines before last line
|
#line_number=4, comments lines before last line
|
||||||
elif (line_number==4) and (not clean_line.startswith(u'CCL')):
|
elif (line_number == 4) and \
|
||||||
|
(not clean_line.startswith(u'CCL')):
|
||||||
song_comments = song_comments + clean_line
|
song_comments = song_comments + clean_line
|
||||||
# split on known separators
|
# split on known separators
|
||||||
author_list = song_author.split(u'/')
|
author_list = song_author.split(u'/')
|
||||||
@ -307,4 +309,3 @@ class CCLIFileImport(SongImport):
|
|||||||
self.ccli_number = song_ccli
|
self.ccli_number = song_ccli
|
||||||
self.comments = song_comments
|
self.comments = song_comments
|
||||||
self.finish()
|
self.finish()
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ from zipfile import ZipFile
|
|||||||
from lxml import objectify
|
from lxml import objectify
|
||||||
from lxml.etree import Error, LxmlError
|
from lxml.etree import Error, LxmlError
|
||||||
|
|
||||||
|
from openlp.core.lib import translate
|
||||||
from openlp.plugins.songs.lib.songimport import SongImport
|
from openlp.plugins.songs.lib.songimport import SongImport
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -170,7 +171,7 @@ class OpenSongImport(SongImport):
|
|||||||
self.authors = []
|
self.authors = []
|
||||||
try:
|
try:
|
||||||
tree = objectify.parse(file)
|
tree = objectify.parse(file)
|
||||||
except Error, LxmlError:
|
except (Error, LxmlError):
|
||||||
log.exception(u'Error parsing XML')
|
log.exception(u'Error parsing XML')
|
||||||
return
|
return
|
||||||
root = tree.getroot()
|
root = tree.getroot()
|
||||||
@ -276,7 +277,8 @@ class OpenSongImport(SongImport):
|
|||||||
if len(our_verse_order) > 0:
|
if len(our_verse_order) > 0:
|
||||||
order = our_verse_order
|
order = our_verse_order
|
||||||
else:
|
else:
|
||||||
log.warn(u'No verse order available for %s, skipping.', self.title)
|
log.warn(u'No verse order available for %s, skipping.',
|
||||||
|
self.title)
|
||||||
for tag in order:
|
for tag in order:
|
||||||
if len(tag) == 1:
|
if len(tag) == 1:
|
||||||
tag = tag + u'1' # Assume it's no.1 if it's not there
|
tag = tag + u'1' # Assume it's no.1 if it's not there
|
||||||
|
Loading…
Reference in New Issue
Block a user