text clean ups

This commit is contained in:
Tim Bentley 2018-01-19 21:31:36 +00:00
parent 4fa63439f4
commit 0ce0231a5f
2 changed files with 20 additions and 10 deletions

View File

@ -384,7 +384,7 @@ class BibleMediaItem(MediaManagerItem):
This initialises the given bible, which means that its book names and their chapter numbers is added to the This initialises the given bible, which means that its book names and their chapter numbers is added to the
combo boxes on the 'Select' Tab. This is not of any importance of the 'Search' Tab. combo boxes on the 'Select' Tab. This is not of any importance of the 'Search' Tab.
:param last_book_id: The "book reference id" of the book which is chosen at the moment. (int) :param last_book: The "book reference id" of the book which is chosen at the moment. (int)
:return: None :return: None
""" """
log.debug('initialise_advanced_bible {bible}, {ref}'.format(bible=self.bible, ref=last_book)) log.debug('initialise_advanced_bible {bible}, {ref}'.format(bible=self.bible, ref=last_book))
@ -1005,14 +1005,17 @@ class BibleMediaItem(MediaManagerItem):
}[self.settings.display_style] }[self.settings.display_style]
return '{{su}}{bracket[0]}{verse_text}{bracket[1]}{{/su}} '.format(verse_text=verse_text, bracket=bracket) return '{{su}}{bracket[0]}{verse_text}{bracket[1]}{{/su}} '.format(verse_text=verse_text, bracket=bracket)
def search(self, string, showError): def search(self, string, show_error=True):
""" """
Search for some Bible verses (by reference). Search for some Bible verses (by reference).
:param string: search string
:param show_error: do we show the error
:return: the results of the search
""" """
if self.bible is None: if self.bible is None:
return [] return []
reference = self.plugin.manager.parse_ref(self.bible.name, string) reference = self.plugin.manager.parse_ref(self.bible.name, string)
search_results = self.plugin.manager.get_verses(self.bible.name, reference, showError) search_results = self.plugin.manager.get_verses(self.bible.name, reference, show_error)
if search_results: if search_results:
verse_text = ' '.join([verse.text for verse in search_results]) verse_text = ' '.join([verse.text for verse in search_results])
return [[string, verse_text]] return [[string, verse_text]]

View File

@ -321,9 +321,12 @@ class SongMediaItem(MediaManagerItem):
:param search_results: A tuple containing (songbook entry, book name, song title, song id) :param search_results: A tuple containing (songbook entry, book name, song title, song id)
:return: None :return: None
""" """
def get_songbook_key(result): def get_songbook_key(text_array):
"""Get the key to sort by""" """
return (get_natural_key(result[1]), get_natural_key(result[0]), get_natural_key(result[2])) Get the key to sort by
:param text_array: the result text to be processed.
"""
return get_natural_key(text_array[1]), get_natural_key(text_array[0]), get_natural_key(text_array[2])
log.debug('display results Book') log.debug('display results Book')
self.list_view.clear() self.list_view.clear()
@ -373,7 +376,7 @@ class SongMediaItem(MediaManagerItem):
""" """
def get_theme_key(song): def get_theme_key(song):
"""Get the key to sort by""" """Get the key to sort by"""
return (get_natural_key(song.theme_name), song.sort_key) return get_natural_key(song.theme_name), song.sort_key
log.debug('display results Themes') log.debug('display results Themes')
self.list_view.clear() self.list_view.clear()
@ -396,7 +399,7 @@ class SongMediaItem(MediaManagerItem):
""" """
def get_cclinumber_key(song): def get_cclinumber_key(song):
"""Get the key to sort by""" """Get the key to sort by"""
return (get_natural_key(song.ccli_number), song.sort_key) return get_natural_key(song.ccli_number), song.sort_key
log.debug('display results CCLI number') log.debug('display results CCLI number')
self.list_view.clear() self.list_view.clear()
@ -460,6 +463,8 @@ class SongMediaItem(MediaManagerItem):
""" """
Called by ServiceManager or SlideController by event passing the Song Id in the payload along with an indicator Called by ServiceManager or SlideController by event passing the Song Id in the payload along with an indicator
to say which type of display is required. to say which type of display is required.
:param song_id: the id of the song
:param preview: show we preview after the update
""" """
log.debug('on_remote_edit for song {song}'.format(song=song_id)) log.debug('on_remote_edit for song {song}'.format(song=song_id))
song_id = int(song_id) song_id = int(song_id)
@ -721,7 +726,8 @@ class SongMediaItem(MediaManagerItem):
self.generate_footer(item, song) self.generate_footer(item, song)
return item return item
def _authors_match(self, song, authors): @staticmethod
def _authors_match(song, authors):
""" """
Checks whether authors from a song in the database match the authors of the song to be imported. Checks whether authors from a song in the database match the authors of the song to be imported.
@ -738,11 +744,12 @@ class SongMediaItem(MediaManagerItem):
# List must be empty at the end # List must be empty at the end
return not author_list return not author_list
def search(self, string, show_error): def search(self, string, show_error=True):
""" """
Search for some songs Search for some songs
:param string: The string to show :param string: The string to show
:param show_error: Is this an error? :param show_error: Is this an error?
:return: the results of the search
""" """
search_results = self.search_entire(string) search_results = self.search_entire(string)
return [[song.id, song.title, song.alternate_title] for song in search_results] return [[song.id, song.title, song.alternate_title] for song in search_results]