示例#1
0
 def on_search_text_button_clicked(self):
     # Save the current search type to the configuration.
     Settings().setValue('%s/last search type' % self.settings_section, self.search_text_edit.current_search_type())
     # Reload the list considering the new search type.
     search_keywords = str(self.search_text_edit.displayText())
     search_type = self.search_text_edit.current_search_type()
     if search_type == SongSearch.Entire:
         log.debug('Entire Song Search')
         search_results = self.search_entire(search_keywords)
         self.display_results_song(search_results)
     elif search_type == SongSearch.Titles:
         log.debug('Titles Search')
         search_string = '%' + clean_string(search_keywords) + '%'
         search_results = self.plugin.manager.get_all_objects(Song, Song.search_title.like(search_string))
         self.display_results_song(search_results)
     elif search_type == SongSearch.Lyrics:
         log.debug('Lyrics Search')
         search_string = '%' + clean_string(search_keywords) + '%'
         search_results = self.plugin.manager.get_all_objects(Song, Song.search_lyrics.like(search_string))
         self.display_results_song(search_results)
     elif search_type == SongSearch.Authors:
         log.debug('Authors Search')
         search_string = '%' + search_keywords + '%'
         search_results = self.plugin.manager.get_all_objects(
             Author, Author.display_name.like(search_string), Author.display_name.asc())
         self.display_results_author(search_results)
     elif search_type == SongSearch.Books:
         log.debug('Songbook Search')
         self.display_results_book(search_keywords)
     elif search_type == SongSearch.Themes:
         log.debug('Theme Search')
         search_string = '%' + search_keywords + '%'
         search_results = self.plugin.manager.get_all_objects(Song, Song.theme_name.like(search_string))
         self.display_results_song(search_results)
     self.check_search_result()
示例#2
0
 def on_search_text_button_clicked(self):
     # Reload the list considering the new search type.
     search_keywords = str(self.search_text_edit.displayText())
     search_type = self.search_text_edit.current_search_type()
     if search_type == SongSearch.Entire:
         log.debug('Entire Song Search')
         search_results = self.search_entire(search_keywords)
         self.display_results_song(search_results)
     elif search_type == SongSearch.Titles:
         log.debug('Titles Search')
         search_string = '%{text}%'.format(text=clean_string(search_keywords))
         search_results = self.plugin.manager.get_all_objects(Song, Song.search_title.like(search_string))
         self.display_results_song(search_results)
     elif search_type == SongSearch.Lyrics:
         log.debug('Lyrics Search')
         search_string = '%{text}%'.format(text=clean_string(search_keywords))
         search_results = self.plugin.manager.get_all_objects(Song, Song.search_lyrics.like(search_string))
         self.display_results_song(search_results)
     elif search_type == SongSearch.Authors:
         log.debug('Authors Search')
         search_string = '%{text}%'.format(text=search_keywords)
         search_results = self.plugin.manager.get_all_objects(
             Author, Author.display_name.like(search_string))
         self.display_results_author(search_results)
     elif search_type == SongSearch.Topics:
         log.debug('Topics Search')
         search_string = '%{text}%'.format(text=search_keywords)
         search_results = self.plugin.manager.get_all_objects(
             Topic, Topic.name.like(search_string))
         self.display_results_topic(search_results)
     elif search_type == SongSearch.Books:
         log.debug('Songbook Search')
         search_keywords = search_keywords.rpartition(' ')
         search_book = '{text}%'.format(text=search_keywords[0])
         search_entry = '{text}%'.format(text=search_keywords[2])
         search_results = (self.plugin.manager.session.query(SongBookEntry.entry, Book.name, Song.title, Song.id)
                           .join(Song)
                           .join(Book)
                           .filter(Book.name.like(search_book), SongBookEntry.entry.like(search_entry),
                                   Song.temporary.is_(False)).all())
         self.display_results_book(search_results)
     elif search_type == SongSearch.Themes:
         log.debug('Theme Search')
         search_string = '%{text}%'.format(text=search_keywords)
         search_results = self.plugin.manager.get_all_objects(
             Song, Song.theme_name.like(search_string))
         self.display_results_themes(search_results)
     elif search_type == SongSearch.Copyright:
         log.debug('Copyright Search')
         search_string = '%{text}%'.format(text=search_keywords)
         search_results = self.plugin.manager.get_all_objects(
             Song, and_(Song.copyright.like(search_string), Song.copyright != ''))
         self.display_results_song(search_results)
     elif search_type == SongSearch.CCLInumber:
         log.debug('CCLI number Search')
         search_string = '%{text}%'.format(text=search_keywords)
         search_results = self.plugin.manager.get_all_objects(
             Song, and_(Song.ccli_number.like(search_string), Song.ccli_number != ''))
         self.display_results_cclinumber(search_results)
示例#3
0
 def on_search_text_button_clicked(self):
     # Reload the list considering the new search type.
     search_keywords = str(self.search_text_edit.displayText())
     search_type = self.search_text_edit.current_search_type()
     if search_type == SongSearch.Entire:
         log.debug('Entire Song Search')
         search_results = self.search_entire(search_keywords)
         self.display_results_song(search_results)
     elif search_type == SongSearch.Titles:
         log.debug('Titles Search')
         search_string = '%{text}%'.format(text=clean_string(search_keywords))
         search_results = self.plugin.manager.get_all_objects(Song, Song.search_title.like(search_string))
         self.display_results_song(search_results)
     elif search_type == SongSearch.Lyrics:
         log.debug('Lyrics Search')
         search_string = '%{text}%'.format(text=clean_string(search_keywords))
         search_results = self.plugin.manager.get_all_objects(Song, Song.search_lyrics.like(search_string))
         self.display_results_song(search_results)
     elif search_type == SongSearch.Authors:
         log.debug('Authors Search')
         search_string = '%{text}%'.format(text=search_keywords)
         search_results = self.plugin.manager.get_all_objects(
             Author, Author.display_name.like(search_string))
         self.display_results_author(search_results)
     elif search_type == SongSearch.Topics:
         log.debug('Topics Search')
         search_string = '%{text}%'.format(text=search_keywords)
         search_results = self.plugin.manager.get_all_objects(
             Topic, Topic.name.like(search_string))
         self.display_results_topic(search_results)
     elif search_type == SongSearch.Books:
         log.debug('Songbook Search')
         search_keywords = search_keywords.rpartition(' ')
         search_book = '{text}%'.format(text=search_keywords[0])
         search_entry = '{text}%'.format(text=search_keywords[2])
         search_results = (self.plugin.manager.session.query(SongBookEntry.entry, Book.name, Song.title, Song.id)
                           .join(Song)
                           .join(Book)
                           .filter(Book.name.like(search_book), SongBookEntry.entry.like(search_entry),
                                   Song.temporary.is_(False)).all())
         self.display_results_book(search_results)
     elif search_type == SongSearch.Themes:
         log.debug('Theme Search')
         search_string = '%{text}%'.format(text=search_keywords)
         search_results = self.plugin.manager.get_all_objects(
             Song, Song.theme_name.like(search_string))
         self.display_results_themes(search_results)
     elif search_type == SongSearch.Copyright:
         log.debug('Copyright Search')
         search_string = '%{text}%'.format(text=search_keywords)
         search_results = self.plugin.manager.get_all_objects(
             Song, and_(Song.copyright.like(search_string), Song.copyright != ''))
         self.display_results_song(search_results)
     elif search_type == SongSearch.CCLInumber:
         log.debug('CCLI number Search')
         search_string = '%{text}%'.format(text=search_keywords)
         search_results = self.plugin.manager.get_all_objects(
             Song, and_(Song.ccli_number.like(search_string), Song.ccli_number != ''))
         self.display_results_cclinumber(search_results)
示例#4
0
 def on_search_text_button_clicked(self):
     # Save the current search type to the configuration.
     Settings().setValue('%s/last search type' % self.settings_section,
                         self.search_text_edit.current_search_type())
     # Reload the list considering the new search type.
     search_keywords = str(self.search_text_edit.displayText())
     search_type = self.search_text_edit.current_search_type()
     if search_type == SongSearch.Entire:
         log.debug('Entire Song Search')
         search_results = self.search_entire(search_keywords)
         self.display_results_song(search_results)
     elif search_type == SongSearch.Titles:
         log.debug('Titles Search')
         search_string = '%' + clean_string(search_keywords) + '%'
         search_results = self.plugin.manager.get_all_objects(
             Song, Song.search_title.like(search_string))
         self.display_results_song(search_results)
     elif search_type == SongSearch.Lyrics:
         log.debug('Lyrics Search')
         search_string = '%' + clean_string(search_keywords) + '%'
         search_results = self.plugin.manager.get_all_objects(
             Song, Song.search_lyrics.like(search_string))
         self.display_results_song(search_results)
     elif search_type == SongSearch.Authors:
         log.debug('Authors Search')
         search_string = '%' + search_keywords + '%'
         search_results = self.plugin.manager.get_all_objects(
             Author, Author.display_name.like(search_string),
             Author.display_name.asc())
         self.display_results_author(search_results)
     elif search_type == SongSearch.Books:
         log.debug('Books Search')
         search_string = '%' + search_keywords + '%'
         search_results = self.plugin.manager.get_all_objects(
             Book, Book.name.like(search_string), Book.name.asc())
         song_number = False
         if not search_results:
             search_keywords = search_keywords.rpartition(' ')
             search_string = '%' + search_keywords[0] + '%'
             search_results = self.plugin.manager.get_all_objects(
                 Book, Book.name.like(search_string), Book.name.asc())
             song_number = re.sub(r'[^0-9]', '', search_keywords[2])
         self.display_results_book(search_results, song_number)
     elif search_type == SongSearch.Themes:
         log.debug('Theme Search')
         search_string = '%' + search_keywords + '%'
         search_results = self.plugin.manager.get_all_objects(
             Song, Song.theme_name.like(search_string))
         self.display_results_song(search_results)
     self.check_search_result()
示例#5
0
 def search_entire(self, search_keywords):
     search_string = '%' + clean_string(search_keywords) + '%'
     return self.plugin.manager.get_all_objects(
         Song,
         or_(
             Song.search_title.like(search_string),
             Song.search_lyrics.like(search_string),
             Song.comments.like(search_string)))
示例#6
0
 def search_entire(self, search_keywords):
     search_string = '%{text}%'.format(text=clean_string(search_keywords))
     return self.plugin.manager.session.query(Song) \
         .join(SongBookEntry, isouter=True) \
         .join(Book, isouter=True) \
         .filter(or_(Book.name.like(search_string), SongBookEntry.entry.like(search_string),
                     # hint: search_title contains alternate title
                     Song.search_title.like(search_string), Song.search_lyrics.like(search_string),
                     Song.comments.like(search_string))) \
         .all()
示例#7
0
 def onSearchTextButtonClicked(self):
     # Save the current search type to the configuration.
     Settings().setValue(u'%s/last search type' % self.settingsSection, self.searchTextEdit.currentSearchType())
     # Reload the list considering the new search type.
     search_keywords = unicode(self.searchTextEdit.displayText())
     search_results = []
     search_type = self.searchTextEdit.currentSearchType()
     if search_type == SongSearch.Entire:
         log.debug(u'Entire Song Search')
         search_results = self.searchEntire(search_keywords)
         self.displayResultsSong(search_results)
     elif search_type == SongSearch.Titles:
         log.debug(u'Titles Search')
         search_results = self.plugin.manager.get_all_objects(Song,
             Song.search_title.like(u'%' + clean_string(search_keywords) + u'%'))
         self.displayResultsSong(search_results)
     elif search_type == SongSearch.Lyrics:
         log.debug(u'Lyrics Search')
         search_results = self.plugin.manager.get_all_objects(Song,
             Song.search_lyrics.like(u'%' + clean_string(search_keywords) + u'%'))
         self.displayResultsSong(search_results)
     elif search_type == SongSearch.Authors:
         log.debug(u'Authors Search')
         search_results = self.plugin.manager.get_all_objects(Author,
             Author.display_name.like(u'%' + search_keywords + u'%'), Author.display_name.asc())
         self.displayResultsAuthor(search_results)
     elif search_type == SongSearch.Books:
         log.debug(u'Books Search')
         search_results = self.plugin.manager.get_all_objects(Book,
             Book.name.like(u'%' + search_keywords + u'%'), Book.name.asc())
         song_number = False
         if not search_results:
             search_keywords = search_keywords.rpartition(' ')
             search_results = self.plugin.manager.get_all_objects(Book,
                 Book.name.like(u'%' + search_keywords[0] + u'%'), Book.name.asc())
             song_number = re.sub(r'[^0-9]', u'', search_keywords[2])
         self.displayResultsBook(search_results, song_number)
     elif search_type == SongSearch.Themes:
         log.debug(u'Theme Search')
         search_results = self.plugin.manager.get_all_objects(Song,
             Song.theme_name.like(u'%' + search_keywords + u'%'))
         self.displayResultsSong(search_results)
     self.checkSearchResult()
示例#8
0
    def clean_string_test(self):
        """
        Test the clean_string() function
        """
        # GIVEN: A "dirty" string
        dirty_string = 'Ain\'t gonna   find\t you there.'

        # WHEN: We run the string through the function
        result = clean_string(dirty_string)

        # THEN: The string should be cleaned up and lower-cased
        self.assertEqual(result, 'aint gonna find you there ', 'The string should be cleaned up properly')
示例#9
0
文件: test_lib.py 项目: jkunle/paul
    def clean_string_test(self):
        """
        Test the clean_string() function
        """
        # GIVEN: A "dirty" string
        dirty_string = 'Ain\'t gonna   find\t you there.'

        # WHEN: We run the string through the function
        result = clean_string(dirty_string)

        # THEN: The string should be cleaned up and lower-cased
        self.assertEqual(result, 'aint gonna find you there ', 'The string should be cleaned up properly')
示例#10
0
 def search_entire(self, search_keywords):
     search_string = '%{text}%'.format(text=clean_string(search_keywords))
     return self.plugin.manager.get_all_objects(
         Song, or_(Song.search_title.like(search_string), Song.search_lyrics.like(search_string),
                   Song.comments.like(search_string)))
示例#11
0
 def searchEntire(self, search_keywords):
     return self.plugin.manager.get_all_objects(Song,
         or_(Song.search_title.like(u'%' + clean_string(search_keywords) + u'%'),
             Song.search_lyrics.like(u'%' + clean_string(search_keywords) + u'%'),
             Song.comments.like(u'%' + search_keywords.lower() + u'%')))