added comments; same fix for import

This commit is contained in:
Andreas Preikschat 2011-04-12 11:55:02 +02:00
parent 962f038c9b
commit 9a1be99781
2 changed files with 6 additions and 4 deletions

View File

@ -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

View File

@ -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)