- added a new Songbeamer property

- replaced try
- enumeration fix

bzr-revno: 1319
This commit is contained in:
Andreas Preikschat 2011-02-20 22:55:15 +00:00 committed by Jon Tibble
commit 624b9e1cfd
3 changed files with 17 additions and 30 deletions

View File

@ -254,9 +254,9 @@ class SongMediaItem(MediaManagerItem):
""" """
if self.searchAsYouType: if self.searchAsYouType:
search_length = 1 search_length = 1
if self.searchTextEdit.currentSearchType() == 1: if self.searchTextEdit.currentSearchType() == SongSearch.Entire:
search_length = 3 search_length = 3
elif self.searchTextEdit.currentSearchType() == 3: elif self.searchTextEdit.currentSearchType() == SongSearch.Lyrics:
search_length = 7 search_length = 7
if len(text) > search_length: if len(text) > search_length:
self.onSearchTextButtonClick() self.onSearchTextButtonClick()

View File

@ -245,6 +245,8 @@ class SongBeamerImport(SongImport):
self.song_number = u'' self.song_number = u''
elif tag_val[0] == u'#Speed': elif tag_val[0] == u'#Speed':
pass pass
elif tag_val[0] == u'Tempo':
pass
elif tag_val[0] == u'#TextAlign': elif tag_val[0] == u'#TextAlign':
pass pass
elif tag_val[0] == u'#Title': elif tag_val[0] == u'#Title':

View File

@ -299,9 +299,9 @@ class OpenLyrics(object):
# Remove chords from xml. # Remove chords from xml.
xml = re.compile(u'<chord name=".*?"/>').sub(u'', xml) xml = re.compile(u'<chord name=".*?"/>').sub(u'', xml)
song_xml = objectify.fromstring(xml) song_xml = objectify.fromstring(xml)
try: if hasattr(song_xml, u'properties'):
properties = song_xml.properties properties = song_xml.properties
except AttributeError: else:
return None return None
song = Song() song = Song()
self._process_copyright(properties, song) self._process_copyright(properties, song)
@ -369,13 +369,11 @@ class OpenLyrics(object):
The song object. The song object.
""" """
authors = [] authors = []
try: if hasattr(properties, u'authors'):
for author in properties.authors.author: for author in properties.authors.author:
display_name = self._text(author) display_name = self._text(author)
if display_name: if display_name:
authors.append(display_name) authors.append(display_name)
except AttributeError:
pass
if not authors: if not authors:
authors.append(SongStrings.AuthorUnknownUnT) authors.append(SongStrings.AuthorUnknownUnT)
for display_name in authors: for display_name in authors:
@ -399,10 +397,8 @@ class OpenLyrics(object):
``song`` ``song``
The song object. The song object.
""" """
try: if hasattr(properties, u'ccliNo'):
song.ccli_number = self._text(properties.ccliNo) song.ccli_number = self._text(properties.ccliNo)
except AttributeError:
song.ccli_number = u''
def _process_comments(self, properties, song): def _process_comments(self, properties, song):
""" """
@ -414,15 +410,13 @@ class OpenLyrics(object):
``song`` ``song``
The song object. The song object.
""" """
try: if hasattr(properties, u'comments'):
comments_list = [] comments_list = []
for comment in properties.comments.comment: for comment in properties.comments.comment:
commenttext = self._text(comment) commenttext = self._text(comment)
if commenttext: if commenttext:
comments_list.append(commenttext) comments_list.append(commenttext)
song.comments = u'\n'.join(comments_list) song.comments = u'\n'.join(comments_list)
except AttributeError:
song.comments = u''
def _process_copyright(self, properties, song): def _process_copyright(self, properties, song):
""" """
@ -434,10 +428,8 @@ class OpenLyrics(object):
``song`` ``song``
The song object. The song object.
""" """
try: if hasattr(properties, u'copyright'):
song.copyright = self._text(properties.copyright) song.copyright = self._text(properties.copyright)
except AttributeError:
song.copyright = u''
def _process_lyrics(self, properties, lyrics, song): def _process_lyrics(self, properties, lyrics, song):
""" """
@ -478,9 +470,9 @@ class OpenLyrics(object):
song.search_lyrics = search_text.lower() song.search_lyrics = search_text.lower()
song.lyrics = unicode(sxml.extract_xml(), u'utf-8') song.lyrics = unicode(sxml.extract_xml(), u'utf-8')
# Process verse order # Process verse order
try: if hasattr(properties, u'verseOrder'):
song.verse_order = self._text(properties.verseOrder) song.verse_order = self._text(properties.verseOrder)
except AttributeError: else:
# We have to process the temp_verse_order, as the verseOrder # We have to process the temp_verse_order, as the verseOrder
# property is not present. # property is not present.
previous_type = u'' previous_type = u''
@ -511,7 +503,7 @@ class OpenLyrics(object):
""" """
song.song_book_id = 0 song.song_book_id = 0
song.song_number = u'' song.song_number = u''
try: if hasattr(properties, u'songbooks'):
for songbook in properties.songbooks.songbook: for songbook in properties.songbooks.songbook:
bookname = self._get(songbook, u'name') bookname = self._get(songbook, u'name')
if bookname: if bookname:
@ -522,15 +514,10 @@ class OpenLyrics(object):
book = Book.populate(name=bookname, publisher=u'') book = Book.populate(name=bookname, publisher=u'')
self.manager.save_object(book) self.manager.save_object(book)
song.song_book_id = book.id song.song_book_id = book.id
try: if hasattr(songbook, u'entry'):
if self._get(songbook, u'entry'): song.song_number = self._get(songbook, u'entry')
song.song_number = self._get(songbook, u'entry')
except AttributeError:
pass
# We only support one song book, so take the first one. # We only support one song book, so take the first one.
break break
except AttributeError:
pass
def _process_titles(self, properties, song): def _process_titles(self, properties, song):
""" """
@ -563,7 +550,7 @@ class OpenLyrics(object):
``song`` ``song``
The song object. The song object.
""" """
try: if hasattr(properties, u'themes'):
for topictext in properties.themes.theme: for topictext in properties.themes.theme:
topictext = self._text(topictext) topictext = self._text(topictext)
if topictext: if topictext:
@ -574,8 +561,6 @@ class OpenLyrics(object):
topic = Topic.populate(name=topictext) topic = Topic.populate(name=topictext)
self.manager.save_object(topic) self.manager.save_object(topic)
song.topics.append(topic) song.topics.append(topic)
except AttributeError:
pass
def _dump_xml(self, xml): def _dump_xml(self, xml):
""" """