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. Generically load a set of objects into a cache and a combobox.
""" """
objects = self.manager.get_all_objects(cls) 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) objects.sort(key=get_key)
combo.clear() combo.clear()
combo.addItem('') combo.addItem('')
@ -347,7 +347,7 @@ 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.
""" """
authors = self.manager.get_all_objects(Author) 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) 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('')
@ -386,7 +386,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
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
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.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)

View File

@ -213,7 +213,7 @@ 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)
get_song_key = lambda song: song.sort_key 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.

View File

@ -123,7 +123,7 @@ class SongMaintenanceForm(QtWidgets.QDialog, Ui_SongMaintenanceDialog, RegistryP
""" """
self.authors_list_widget.clear() self.authors_list_widget.clear()
authors = self.manager.get_all_objects(Author) 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) authors.sort(key=get_author_key)
for author in authors: for author in authors:
if author.display_name: if author.display_name:
@ -139,7 +139,7 @@ class SongMaintenanceForm(QtWidgets.QDialog, Ui_SongMaintenanceDialog, RegistryP
""" """
self.topics_list_widget.clear() self.topics_list_widget.clear()
topics = self.manager.get_all_objects(Topic) 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) 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)
@ -152,7 +152,7 @@ class SongMaintenanceForm(QtWidgets.QDialog, Ui_SongMaintenanceDialog, RegistryP
""" """
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)
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) 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))

View File

@ -261,7 +261,7 @@ class SongMediaItem(MediaManagerItem):
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()
get_song_key = lambda song: song.sort_key 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
@ -286,10 +286,10 @@ class SongMediaItem(MediaManagerItem):
""" """
log.debug('display results Author') log.debug('display results Author')
self.list_view.clear() 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) search_results.sort(key=get_author_key)
for author in search_results: 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) 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
@ -309,7 +309,8 @@ class SongMediaItem(MediaManagerItem):
""" """
log.debug('display results Book') log.debug('display results Book')
self.list_view.clear() 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) 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
@ -329,10 +330,10 @@ class SongMediaItem(MediaManagerItem):
""" """
log.debug('display results Topic') log.debug('display results Topic')
self.list_view.clear() 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) search_results.sort(key=get_topic_key)
for topic in search_results: 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) 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
@ -352,7 +353,7 @@ class SongMediaItem(MediaManagerItem):
""" """
log.debug('display results Themes') log.debug('display results Themes')
self.list_view.clear() 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) 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
@ -372,7 +373,7 @@ class SongMediaItem(MediaManagerItem):
""" """
log.debug('display results CCLI number') log.debug('display results CCLI number')
self.list_view.clear() 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) 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