Filename too long in openlyrics export

This commit is contained in:
Jonathan Corwin 2011-06-19 22:11:29 +01:00
parent 553353cf7e
commit 099b62f233
1 changed files with 3 additions and 1 deletions

View File

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