← Back to team overview

openlp-core team mailing list archive

Re: [Merge] lp:~minkus/openlp/naturalsortfix into lp:openlp

 

Save the lines below as "pep8fix.patch" and then either use "bzr patch" or "patch" by itself to apply the patch to your code.


=== modified file 'openlp/plugins/songs/forms/editsongform.py'
--- openlp/plugins/songs/forms/editsongform.py  2016-04-19 19:32:23 +0000
+++ openlp/plugins/songs/forms/editsongform.py  2016-04-23 14:01:31 +0000
@@ -111,8 +111,11 @@
         """
         Generically load a set of objects into a cache and a combobox.
         """
+        def get_key(obj):
+            """Get the key to sort by"""
+            return get_natural_key(obj.name)
+
         objects = self.manager.get_all_objects(cls)
-        def get_key(object): return get_natural_key(object.name)
         objects.sort(key=get_key)
         combo.clear()
         combo.addItem('')
@@ -346,8 +349,11 @@
         """
         Load the authors from the database into the combobox.
         """
+        def get_author_key(author):
+            """Get the key to sort by"""
+            return get_natural_key(author.display_name)
+
         authors = self.manager.get_all_objects(Author)
-        def get_author_key(author): return get_natural_key(author.display_name)
         authors.sort(key=get_author_key)
         self.authors_combo_box.clear()
         self.authors_combo_box.addItem('')
@@ -383,10 +389,13 @@
         """
         Load the themes into a combobox.
         """
+        def get_theme_key(theme):
+            """Get the key to sort by"""
+            return get_natural_key(theme)
+
         self.theme_combo_box.clear()
         self.theme_combo_box.addItem('')
         self.themes = theme_list
-        def get_theme_key(theme): return get_natural_key(theme)
         self.themes.sort(key=get_theme_key)
         self.theme_combo_box.addItems(theme_list)
         set_case_insensitive_completer(self.themes, self.theme_combo_box)

=== modified file 'openlp/plugins/songs/forms/songexportform.py'
--- openlp/plugins/songs/forms/songexportform.py        2016-04-19 19:32:23 +0000
+++ openlp/plugins/songs/forms/songexportform.py        2016-04-23 14:02:13 +0000
@@ -203,6 +203,10 @@
         """
         Set default form values for the song export wizard.
         """
+        def get_song_key(song):
+            """Get the key to sort by"""
+            return song.sort_key
+
         self.restart()
         self.finish_button.setVisible(False)
         self.cancel_button.setVisible(True)
@@ -213,7 +217,6 @@
         # Load the list of songs.
         self.application.set_busy_cursor()
         songs = self.plugin.manager.get_all_objects(Song)
-        def get_song_key(song): return song.sort_key
         songs.sort(key=get_song_key)
         for song in songs:
             # No need to export temporary songs.

=== modified file 'openlp/plugins/songs/forms/songmaintenanceform.py'
--- openlp/plugins/songs/forms/songmaintenanceform.py   2016-04-19 19:32:23 +0000
+++ openlp/plugins/songs/forms/songmaintenanceform.py   2016-04-23 14:03:22 +0000
@@ -121,9 +121,12 @@
         """
         Reloads the Authors list.
         """
+        def get_author_key(author):
+            """Get the key to sort by"""
+            return get_natural_key(author.display_name)
+
         self.authors_list_widget.clear()
         authors = self.manager.get_all_objects(Author)
-        def get_author_key(author): return get_natural_key(author.display_name)
         authors.sort(key=get_author_key)
         for author in authors:
             if author.display_name:
@@ -137,9 +140,12 @@
         """
         Reloads the Topics list.
         """
+        def get_topic_key(topic):
+            """Get the key to sort by"""
+            return get_natural_key(topic.name)
+
         self.topics_list_widget.clear()
         topics = self.manager.get_all_objects(Topic)
-        def get_topic_key(topic): return get_natural_key(topic.name)
         topics.sort(key=get_topic_key)
         for topic in topics:
             topic_name = QtWidgets.QListWidgetItem(topic.name)
@@ -150,9 +156,12 @@
         """
         Reloads the Books list.
         """
+        def get_book_key(book):
+            """Get the key to sort by"""
+            return get_natural_key(book.name)
+
         self.song_books_list_widget.clear()
         books = self.manager.get_all_objects(Book)
-        def get_book_key(book): return get_natural_key(book.name)
         books.sort(key=get_book_key)
         for book in books:
             book_name = QtWidgets.QListWidgetItem('%s (%s)' % (book.name, book.publisher))

=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py       2016-04-19 19:32:23 +0000
+++ openlp/plugins/songs/lib/mediaitem.py       2016-04-23 13:58:38 +0000
@@ -258,10 +258,13 @@
         :param search_results: A list of db Song objects
         :return: None
         """
+        def get_song_key(song):
+            """Get the key to sort by"""
+            return song.sort_key
+
         log.debug('display results Song')
         self.save_auto_select_id()
         self.list_view.clear()
-        def get_song_key(song): return song.sort_key
         search_results.sort(key=get_song_key)
         for song in search_results:
             # Do not display temporary songs
@@ -284,12 +287,18 @@
         :param search_results: A list of db Author objects
         :return: None
         """
+        def get_author_key(author):
+            """Get the key to sort by"""
+            return get_natural_key(author.display_name)
+
+        def get_song_key(song):
+            """Get the key to sort by"""
+            return song.sort_key
+
         log.debug('display results Author')
         self.list_view.clear()
-        def get_author_key(author): return get_natural_key(author.display_name)
         search_results.sort(key=get_author_key)
         for author in search_results:
-            def get_song_key(song): return song.sort_key
             author.songs.sort(key=get_song_key)
             for song in author.songs:
                 # Do not display temporary songs
@@ -307,10 +316,12 @@
         :param search_results: A list of db SongBookEntry objects
         :return: None
         """
+        def get_songbook_key(songbook_entry):
+            """Get the key to sort by"""
+            return (get_natural_key(songbook_entry.songbook.name), get_natural_key(songbook_entry.entry))
+
         log.debug('display results Book')
         self.list_view.clear()
-        def get_songbook_key(songbook_entry): return (get_natural_key(songbook_entry.songbook.name),
-                                                      get_natural_key(songbook_entry.entry))
         search_results.sort(key=get_songbook_key)
         for songbook_entry in search_results:
             # Do not display temporary songs
@@ -328,12 +339,18 @@
         :param search_results: A list of db Topic objects
         :return: None
         """
+        def get_topic_key(topic):
+            """Get the key to sort by"""
+            return get_natural_key(topic.name)
+
+        def get_song_key(song):
+            """Get the key to sort by"""
+            return song.sort_key
+
         log.debug('display results Topic')
         self.list_view.clear()
-        def get_topic_key(topic): return get_natural_key(topic.name)
         search_results.sort(key=get_topic_key)
         for topic in search_results:
-            def get_song_key(song): return song.sort_key
             topic.songs.sort(key=get_song_key)
             for song in topic.songs:
                 # Do not display temporary songs
@@ -351,9 +368,12 @@
         :param search_results: A list of db Song objects
         :return: None
         """
+        def get_theme_key(song):
+            """Get the key to sort by"""
+            return (get_natural_key(song.theme_name), song.sort_key)
+
         log.debug('display results Themes')
         self.list_view.clear()
-        def get_theme_key(song): return (get_natural_key(song.theme_name), song.sort_key)
         search_results.sort(key=get_theme_key)
         for song in search_results:
             # Do not display temporary songs
@@ -371,9 +391,12 @@
         :param search_results: A list of db Song objects
         :return: None
         """
+        def get_cclinumber_key(song):
+            """Get the key to sort by"""
+            return (get_natural_key(song.ccli_number), song.sort_key)
+
         log.debug('display results CCLI number')
         self.list_view.clear()
-        def get_cclinumber_key(song): return (get_natural_key(song.ccli_number), song.sort_key)
         search_results.sort(key=get_cclinumber_key)
         for song in search_results:
             # Do not display temporary songs


-- 
https://code.launchpad.net/~minkus/openlp/naturalsortfix/+merge/292101
Your team OpenLP Core is subscribed to branch lp:openlp.


References