forked from openlp/openlp
Resolve pep8 errors - separate def, two line split
This commit is contained in:
parent
4b088acc93
commit
1e9b7148f5
@ -111,8 +111,11 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
|||||||
"""
|
"""
|
||||||
Generically load a set of objects into a cache and a combobox.
|
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)
|
objects = self.manager.get_all_objects(cls)
|
||||||
def get_key(object): return get_natural_key(object.name)
|
|
||||||
objects.sort(key=get_key)
|
objects.sort(key=get_key)
|
||||||
combo.clear()
|
combo.clear()
|
||||||
combo.addItem('')
|
combo.addItem('')
|
||||||
@ -346,8 +349,11 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
|||||||
"""
|
"""
|
||||||
Load the authors from the database into the combobox.
|
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)
|
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)
|
authors.sort(key=get_author_key)
|
||||||
self.authors_combo_box.clear()
|
self.authors_combo_box.clear()
|
||||||
self.authors_combo_box.addItem('')
|
self.authors_combo_box.addItem('')
|
||||||
@ -383,10 +389,13 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
|||||||
"""
|
"""
|
||||||
Load the themes into a combobox.
|
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.clear()
|
||||||
self.theme_combo_box.addItem('')
|
self.theme_combo_box.addItem('')
|
||||||
self.themes = theme_list
|
self.themes = theme_list
|
||||||
def get_theme_key(theme): return get_natural_key(theme)
|
|
||||||
self.themes.sort(key=get_theme_key)
|
self.themes.sort(key=get_theme_key)
|
||||||
self.theme_combo_box.addItems(theme_list)
|
self.theme_combo_box.addItems(theme_list)
|
||||||
set_case_insensitive_completer(self.themes, self.theme_combo_box)
|
set_case_insensitive_completer(self.themes, self.theme_combo_box)
|
||||||
|
@ -203,6 +203,10 @@ class SongExportForm(OpenLPWizard):
|
|||||||
"""
|
"""
|
||||||
Set default form values for the song export wizard.
|
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.restart()
|
||||||
self.finish_button.setVisible(False)
|
self.finish_button.setVisible(False)
|
||||||
self.cancel_button.setVisible(True)
|
self.cancel_button.setVisible(True)
|
||||||
@ -213,7 +217,6 @@ class SongExportForm(OpenLPWizard):
|
|||||||
# Load the list of songs.
|
# Load the list of songs.
|
||||||
self.application.set_busy_cursor()
|
self.application.set_busy_cursor()
|
||||||
songs = self.plugin.manager.get_all_objects(Song)
|
songs = self.plugin.manager.get_all_objects(Song)
|
||||||
def get_song_key(song): return song.sort_key
|
|
||||||
songs.sort(key=get_song_key)
|
songs.sort(key=get_song_key)
|
||||||
for song in songs:
|
for song in songs:
|
||||||
# No need to export temporary songs.
|
# No need to export temporary songs.
|
||||||
|
@ -121,9 +121,12 @@ class SongMaintenanceForm(QtWidgets.QDialog, Ui_SongMaintenanceDialog, RegistryP
|
|||||||
"""
|
"""
|
||||||
Reloads the Authors list.
|
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()
|
self.authors_list_widget.clear()
|
||||||
authors = self.manager.get_all_objects(Author)
|
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)
|
authors.sort(key=get_author_key)
|
||||||
for author in authors:
|
for author in authors:
|
||||||
if author.display_name:
|
if author.display_name:
|
||||||
@ -137,9 +140,12 @@ class SongMaintenanceForm(QtWidgets.QDialog, Ui_SongMaintenanceDialog, RegistryP
|
|||||||
"""
|
"""
|
||||||
Reloads the Topics list.
|
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()
|
self.topics_list_widget.clear()
|
||||||
topics = self.manager.get_all_objects(Topic)
|
topics = self.manager.get_all_objects(Topic)
|
||||||
def get_topic_key(topic): return get_natural_key(topic.name)
|
|
||||||
topics.sort(key=get_topic_key)
|
topics.sort(key=get_topic_key)
|
||||||
for topic in topics:
|
for topic in topics:
|
||||||
topic_name = QtWidgets.QListWidgetItem(topic.name)
|
topic_name = QtWidgets.QListWidgetItem(topic.name)
|
||||||
@ -150,9 +156,12 @@ class SongMaintenanceForm(QtWidgets.QDialog, Ui_SongMaintenanceDialog, RegistryP
|
|||||||
"""
|
"""
|
||||||
Reloads the Books list.
|
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()
|
self.song_books_list_widget.clear()
|
||||||
books = self.manager.get_all_objects(Book)
|
books = self.manager.get_all_objects(Book)
|
||||||
def get_book_key(book): return get_natural_key(book.name)
|
|
||||||
books.sort(key=get_book_key)
|
books.sort(key=get_book_key)
|
||||||
for book in books:
|
for book in books:
|
||||||
book_name = QtWidgets.QListWidgetItem('%s (%s)' % (book.name, book.publisher))
|
book_name = QtWidgets.QListWidgetItem('%s (%s)' % (book.name, book.publisher))
|
||||||
|
@ -258,10 +258,13 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
:param search_results: A list of db Song objects
|
:param search_results: A list of db Song objects
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
|
def get_song_key(song):
|
||||||
|
"""Get the key to sort by"""
|
||||||
|
return song.sort_key
|
||||||
|
|
||||||
log.debug('display results Song')
|
log.debug('display results Song')
|
||||||
self.save_auto_select_id()
|
self.save_auto_select_id()
|
||||||
self.list_view.clear()
|
self.list_view.clear()
|
||||||
def get_song_key(song): return song.sort_key
|
|
||||||
search_results.sort(key=get_song_key)
|
search_results.sort(key=get_song_key)
|
||||||
for song in search_results:
|
for song in search_results:
|
||||||
# Do not display temporary songs
|
# Do not display temporary songs
|
||||||
@ -284,12 +287,18 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
:param search_results: A list of db Author objects
|
:param search_results: A list of db Author objects
|
||||||
:return: None
|
: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')
|
log.debug('display results Author')
|
||||||
self.list_view.clear()
|
self.list_view.clear()
|
||||||
def get_author_key(author): return get_natural_key(author.display_name)
|
|
||||||
search_results.sort(key=get_author_key)
|
search_results.sort(key=get_author_key)
|
||||||
for author in search_results:
|
for author in search_results:
|
||||||
def get_song_key(song): return song.sort_key
|
|
||||||
author.songs.sort(key=get_song_key)
|
author.songs.sort(key=get_song_key)
|
||||||
for song in author.songs:
|
for song in author.songs:
|
||||||
# Do not display temporary songs
|
# Do not display temporary songs
|
||||||
@ -307,10 +316,12 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
:param search_results: A list of db SongBookEntry objects
|
:param search_results: A list of db SongBookEntry objects
|
||||||
:return: None
|
: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')
|
log.debug('display results Book')
|
||||||
self.list_view.clear()
|
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)
|
search_results.sort(key=get_songbook_key)
|
||||||
for songbook_entry in search_results:
|
for songbook_entry in search_results:
|
||||||
# Do not display temporary songs
|
# Do not display temporary songs
|
||||||
@ -328,12 +339,18 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
:param search_results: A list of db Topic objects
|
:param search_results: A list of db Topic objects
|
||||||
:return: None
|
: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')
|
log.debug('display results Topic')
|
||||||
self.list_view.clear()
|
self.list_view.clear()
|
||||||
def get_topic_key(topic): return get_natural_key(topic.name)
|
|
||||||
search_results.sort(key=get_topic_key)
|
search_results.sort(key=get_topic_key)
|
||||||
for topic in search_results:
|
for topic in search_results:
|
||||||
def get_song_key(song): return song.sort_key
|
|
||||||
topic.songs.sort(key=get_song_key)
|
topic.songs.sort(key=get_song_key)
|
||||||
for song in topic.songs:
|
for song in topic.songs:
|
||||||
# Do not display temporary songs
|
# Do not display temporary songs
|
||||||
@ -351,9 +368,12 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
:param search_results: A list of db Song objects
|
:param search_results: A list of db Song objects
|
||||||
:return: None
|
: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')
|
log.debug('display results Themes')
|
||||||
self.list_view.clear()
|
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)
|
search_results.sort(key=get_theme_key)
|
||||||
for song in search_results:
|
for song in search_results:
|
||||||
# Do not display temporary songs
|
# Do not display temporary songs
|
||||||
@ -371,9 +391,12 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
:param search_results: A list of db Song objects
|
:param search_results: A list of db Song objects
|
||||||
:return: None
|
: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')
|
log.debug('display results CCLI number')
|
||||||
self.list_view.clear()
|
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)
|
search_results.sort(key=get_cclinumber_key)
|
||||||
for song in search_results:
|
for song in search_results:
|
||||||
# Do not display temporary songs
|
# Do not display temporary songs
|
||||||
|
Loading…
Reference in New Issue
Block a user