no xml raises XMLSyntaxError, that is why this is not needed

This commit is contained in:
Andreas Preikschat 2011-04-18 21:24:06 +02:00
parent 6baefdadce
commit 974a90a173
3 changed files with 3 additions and 9 deletions

View File

@ -128,9 +128,7 @@ class FoilPresenterImport(SongImport):
try: try:
parsed_file = etree.parse(file_path, parser) parsed_file = etree.parse(file_path, parser)
xml = unicode(etree.tostring(parsed_file)) xml = unicode(etree.tostring(parsed_file))
if self.FoilPresenter.xml_to_song(xml) is None: self.FoilPresenter.xml_to_song(xml)
self.log_error(file_path, SongStrings.NoXML)
log.debug(u'File could not be imported: %s' % file_path)
except etree.XMLSyntaxError: except etree.XMLSyntaxError:
self.log_error(file_path, SongStrings.XMLSyntaxError) self.log_error(file_path, SongStrings.XMLSyntaxError)
log.exception(u'XML syntax error in file %s' % file_path) log.exception(u'XML syntax error in file %s' % file_path)
@ -213,7 +211,7 @@ class FoilPresenter(object):
""" """
# No xml get out of here. # No xml get out of here.
if not xml: if not xml:
return None return
if xml[:5] == u'<?xml': if xml[:5] == u'<?xml':
xml = xml[38:] xml = xml[38:]
song = Song() song = Song()
@ -237,7 +235,6 @@ class FoilPresenter(object):
self._process_topics(foilpresenterfolie, song) self._process_topics(foilpresenterfolie, song)
clean_song(self.manager, song) clean_song(self.manager, song)
self.manager.save_object(song) self.manager.save_object(song)
return song.id
def _child(self, element): def _child(self, element):
""" """

View File

@ -68,9 +68,7 @@ class OpenLyricsImport(SongImport):
# special characters in the path (see lp:757673 and lp:744337). # special characters in the path (see lp:757673 and lp:744337).
parsed_file = etree.parse(open(file_path, u'r'), parser) parsed_file = etree.parse(open(file_path, u'r'), parser)
xml = unicode(etree.tostring(parsed_file)) xml = unicode(etree.tostring(parsed_file))
if self.openLyrics.xml_to_song(xml) is None: self.openLyrics.xml_to_song(xml)
log.debug(u'File could not be imported: %s' % file_path)
self.log_error(file_path, SongStrings.NoXML)
except etree.XMLSyntaxError: except etree.XMLSyntaxError:
log.exception(u'XML syntax error in file %s' % file_path) log.exception(u'XML syntax error in file %s' % file_path)
self.log_error(file_path, SongStrings.XMLSyntaxError) self.log_error(file_path, SongStrings.XMLSyntaxError)

View File

@ -38,7 +38,6 @@ class SongStrings(object):
Authors = translate('OpenLP.Ui', 'Authors', 'Plural') Authors = translate('OpenLP.Ui', 'Authors', 'Plural')
AuthorUnknown = u'Author Unknown' # Used to populate the database. AuthorUnknown = u'Author Unknown' # Used to populate the database.
CopyrightSymbol = translate('OpenLP.Ui', '\xa9', 'Copyright symbol.') CopyrightSymbol = translate('OpenLP.Ui', '\xa9', 'Copyright symbol.')
NoXML = translate('OpenLP.Ui', 'Song does not contain any XML')
SongBook = translate('OpenLP.Ui', 'Song Book', 'Singular') SongBook = translate('OpenLP.Ui', 'Song Book', 'Singular')
SongBooks = translate('OpenLP.Ui', 'Song Books', 'Plural') SongBooks = translate('OpenLP.Ui', 'Song Books', 'Plural')
SongIncomplete = translate('OpenLP.Ui','Title and/or verses not found') SongIncomplete = translate('OpenLP.Ui','Title and/or verses not found')