Coding standards fix - E731 do not assign a lambda expression, use a def for pep8

This commit is contained in:
Chris Hill 2016-04-19 20:32:23 +01:00
parent d76965f8fd
commit 4b088acc93
4 changed files with 16 additions and 15 deletions

View File

@ -112,7 +112,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
Generically load a set of objects into a cache and a combobox.
"""
objects = self.manager.get_all_objects(cls)
get_key = lambda object: get_natural_key(object.name)
def get_key(object): return get_natural_key(object.name)
objects.sort(key=get_key)
combo.clear()
combo.addItem('')
@ -347,7 +347,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
Load the authors from the database into the combobox.
"""
authors = self.manager.get_all_objects(Author)
get_author_key = lambda author: get_natural_key(author.display_name)
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('')
@ -386,7 +386,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
self.theme_combo_box.clear()
self.theme_combo_box.addItem('')
self.themes = theme_list
get_theme_key = lambda theme: get_natural_key(theme)
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)

View File

@ -213,7 +213,7 @@ class SongExportForm(OpenLPWizard):
# Load the list of songs.
self.application.set_busy_cursor()
songs = self.plugin.manager.get_all_objects(Song)
get_song_key = lambda song: song.sort_key
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.

View File

@ -123,7 +123,7 @@ class SongMaintenanceForm(QtWidgets.QDialog, Ui_SongMaintenanceDialog, RegistryP
"""
self.authors_list_widget.clear()
authors = self.manager.get_all_objects(Author)
get_author_key = lambda author: get_natural_key(author.display_name)
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:
@ -139,7 +139,7 @@ class SongMaintenanceForm(QtWidgets.QDialog, Ui_SongMaintenanceDialog, RegistryP
"""
self.topics_list_widget.clear()
topics = self.manager.get_all_objects(Topic)
get_topic_key = lambda topic: get_natural_key(topic.name)
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)
@ -152,7 +152,7 @@ class SongMaintenanceForm(QtWidgets.QDialog, Ui_SongMaintenanceDialog, RegistryP
"""
self.song_books_list_widget.clear()
books = self.manager.get_all_objects(Book)
get_book_key = lambda book: get_natural_key(book.name)
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))

View File

@ -261,7 +261,7 @@ class SongMediaItem(MediaManagerItem):
log.debug('display results Song')
self.save_auto_select_id()
self.list_view.clear()
get_song_key = lambda song: song.sort_key
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
@ -286,10 +286,10 @@ class SongMediaItem(MediaManagerItem):
"""
log.debug('display results Author')
self.list_view.clear()
get_author_key = lambda author: get_natural_key(author.display_name)
def get_author_key(author): return get_natural_key(author.display_name)
search_results.sort(key=get_author_key)
for author in search_results:
get_song_key = lambda song: song.sort_key
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
@ -309,7 +309,8 @@ class SongMediaItem(MediaManagerItem):
"""
log.debug('display results Book')
self.list_view.clear()
get_songbook_key = lambda songbook_entry:(get_natural_key(songbook_entry.songbook.name), get_natural_key(songbook_entry.entry))
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
@ -329,10 +330,10 @@ class SongMediaItem(MediaManagerItem):
"""
log.debug('display results Topic')
self.list_view.clear()
get_topic_key = lambda topic: get_natural_key(topic.name)
def get_topic_key(topic): return get_natural_key(topic.name)
search_results.sort(key=get_topic_key)
for topic in search_results:
get_song_key = lambda song: song.sort_key
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
@ -352,7 +353,7 @@ class SongMediaItem(MediaManagerItem):
"""
log.debug('display results Themes')
self.list_view.clear()
get_theme_key = lambda song: (get_natural_key(song.theme_name), song.sort_key)
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
@ -372,7 +373,7 @@ class SongMediaItem(MediaManagerItem):
"""
log.debug('display results CCLI number')
self.list_view.clear()
get_cclinumber_key = lambda song: (get_natural_key(song.ccli_number), song.sort_key)
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