From 9a1be997811c0167587d7f8cadecf622e5d6d830 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 12 Apr 2011 11:55:02 +0200 Subject: [PATCH] added comments; same fix for import --- openlp/plugins/songs/lib/openlyricsexport.py | 6 +++--- openlp/plugins/songs/lib/openlyricsimport.py | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/songs/lib/openlyricsexport.py b/openlp/plugins/songs/lib/openlyricsexport.py index 17cc14421..59b720d3e 100644 --- a/openlp/plugins/songs/lib/openlyricsexport.py +++ b/openlp/plugins/songs/lib/openlyricsexport.py @@ -73,8 +73,8 @@ class OpenLyricsExport(object): u', '.join([author.display_name for author in song.authors])) filename = re.sub( r'[/\\?*|<>\[\]":<>+%]+', u'_', filename).strip(u'_') - file_object = open(os.path.join(self.save_path, filename), u'w') - tree.write(file_object, + # 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'), encoding=u'utf-8', xml_declaration=True, pretty_print=True) - file_object.close() return True diff --git a/openlp/plugins/songs/lib/openlyricsimport.py b/openlp/plugins/songs/lib/openlyricsimport.py index 208ef3e52..c29abc0b5 100644 --- a/openlp/plugins/songs/lib/openlyricsimport.py +++ b/openlp/plugins/songs/lib/openlyricsimport.py @@ -63,7 +63,9 @@ class OpenLyricsImport(SongImport): self.import_wizard.incrementProgressBar( WizardStrings.ImportingType % os.path.basename(file_path)) try: - parsed_file = etree.parse(file_path, parser) + # Pass a file object, because lxml does not cope with some + # special characters in the path (see lp:757673 and lp:744337). + parsed_file = etree.parse(open(file_path, u'r'), parser) xml = unicode(etree.tostring(parsed_file)) if self.openLyrics.xml_to_song(xml) is None: log.debug(u'File could not be imported: %s' % file_path)