Some minor syntactic sugar.

This commit is contained in:
Raoul Snyman 2010-08-26 22:52:54 +02:00
parent 364940c547
commit dfe8bbae9c

View File

@ -75,18 +75,18 @@ class OpenLPSongImport(SongImport):
The :class:`OpenLPSongImport` class provides OpenLP with the ability to The :class:`OpenLPSongImport` class provides OpenLP with the ability to
import song databases from other installations of OpenLP. import song databases from other installations of OpenLP.
""" """
def __init__(self, master_manager, **kwargs): def __init__(self, manager, **kwargs):
""" """
Initialise the import. Initialise the import.
``master_manager`` ``manager``
The song manager for the running OpenLP installation. The song manager for the running OpenLP installation.
``source_db`` ``source_db``
The database providing the data to import. The database providing the data to import.
""" """
SongImport.__init__(self, master_manager) SongImport.__init__(self, manager)
self.master_manager = master_manager #self.master_manager = master_manager
self.import_source = u'sqlite:///%s' % kwargs[u'filename'] self.import_source = u'sqlite:///%s' % kwargs[u'filename']
log.debug(self.import_source) log.debug(self.import_source)
self.source_session = None self.source_session = None
@ -167,7 +167,7 @@ class OpenLPSongImport(SongImport):
new_song.ccli_number = song.ccli_number new_song.ccli_number = song.ccli_number
if song.authors: if song.authors:
for author in song.authors: for author in song.authors:
existing_author = self.master_manager.get_object_filtered( existing_author = self.manager.get_object_filtered(
Author, Author.display_name == author.display_name) Author, Author.display_name == author.display_name)
if existing_author: if existing_author:
new_song.authors.append(existing_author) new_song.authors.append(existing_author)
@ -177,7 +177,7 @@ class OpenLPSongImport(SongImport):
last_name=author.last_name, last_name=author.last_name,
display_name=author.display_name)) display_name=author.display_name))
else: else:
au = self.master_manager.get_object_filtered(Author, au = self.manager.get_object_filtered(Author,
Author.display_name == u'Author Unknown') Author.display_name == u'Author Unknown')
if au: if au:
new_song.authors.append(au) new_song.authors.append(au)
@ -185,7 +185,7 @@ class OpenLPSongImport(SongImport):
new_song.authors.append(Author.populate( new_song.authors.append(Author.populate(
display_name=u'Author Unknown')) display_name=u'Author Unknown'))
if song.book: if song.book:
existing_song_book = self.master_manager.get_object_filtered( existing_song_book = self.manager.get_object_filtered(
Book, Book.name == song.book.name) Book, Book.name == song.book.name)
if existing_song_book: if existing_song_book:
new_song.book = existing_song_book new_song.book = existing_song_book
@ -194,7 +194,7 @@ class OpenLPSongImport(SongImport):
publisher=song.book.publisher) publisher=song.book.publisher)
if song.topics: if song.topics:
for topic in song.topics: for topic in song.topics:
existing_topic = self.master_manager.get_object_filtered( existing_topic = self.manager.get_object_filtered(
Topic, Topic.name == topic.name) Topic, Topic.name == topic.name)
if existing_topic: if existing_topic:
new_song.topics.append(existing_topic) new_song.topics.append(existing_topic)
@ -204,12 +204,12 @@ class OpenLPSongImport(SongImport):
# if song.media_files: # if song.media_files:
# for media_file in song.media_files: # for media_file in song.media_files:
# existing_media_file = \ # existing_media_file = \
# self.master_manager.get_object_filtered(MediaFile, # self.manager.get_object_filtered(MediaFile,
# MediaFile.file_name == media_file.file_name) # MediaFile.file_name == media_file.file_name)
# if existing_media_file: # if existing_media_file:
# new_song.media_files.append(existing_media_file) # new_song.media_files.append(existing_media_file)
# else: # else:
# new_song.media_files.append(MediaFile.populate( # new_song.media_files.append(MediaFile.populate(
# file_name=media_file.file_name)) # file_name=media_file.file_name))
self.master_manager.save_object(new_song) self.manager.save_object(new_song)
engine.dispose() engine.dispose()