From 099b62f233d15ef8735eab5a77c0e8c713b0f9cf Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sun, 19 Jun 2011 22:11:29 +0100 Subject: [PATCH 1/2] Filename too long in openlyrics export --- openlp/plugins/songs/lib/openlyricsexport.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/openlyricsexport.py b/openlp/plugins/songs/lib/openlyricsexport.py index d6e21ee51..6ba1fabe7 100644 --- a/openlp/plugins/songs/lib/openlyricsexport.py +++ b/openlp/plugins/songs/lib/openlyricsexport.py @@ -70,10 +70,12 @@ class OpenLyricsExport(object): song.title) xml = openLyrics.song_to_xml(song) tree = etree.ElementTree(etree.fromstring(xml)) - filename = u'%s (%s).xml' % (song.title, + filename = u'%s (%s)' % (song.title, u', '.join([author.display_name for author in song.authors])) filename = re.sub( r'[/\\?*|<>\[\]":<>+%]+', u'_', filename).strip(u'_') + # Ensure the filename isn't too long for some filesystems + filename = u'%s.xml' % filename[0:250 - len(self.save_path)] # Pass a file object, because lxml does not cope with some special # characters in the path (see lp:757673 and lp:744337). tree.write(open(os.path.join(self.save_path, filename), u'w'), From f3b7e609e979285ad92c2c5f5df02834b6e79476 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sun, 19 Jun 2011 23:18:06 +0100 Subject: [PATCH 2/2] Don't duplicate songs if a single author contains a comma --- openlp/plugins/songs/lib/mediaitem.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 5c203c630..cd7484df9 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -467,23 +467,20 @@ class SongMediaItem(MediaManagerItem): search_results = self.plugin.manager.get_all_objects(Song, Song.search_title == item.data_string[u'title'], Song.search_title.asc()) - author_list = item.data_string[u'authors'].split(u', ') editId = 0 add_song = True if search_results: for song in search_results: + author_list = item.data_string[u'authors'] same_authors = True - # If the author counts are different, we do not have to do any - # further checking. - if len(song.authors) == len(author_list): - for author in song.authors: - if author.display_name not in author_list: - same_authors = False - else: - same_authors = False - # All authors are the same, so we can stop here and the song - # does not have to be saved. - if same_authors: + for author in song.authors: + if author.display_name in author_list: + author_list = author_list.replace(author.display_name, + u'', 1) + else: + same_authors = False + break + if same_authors and author_list.strip(u', ') == u'': add_song = False editId = song.id break