forked from openlp/openlp
Filename too long in openlyrics export
This commit is contained in:
parent
553353cf7e
commit
099b62f233
@ -70,10 +70,12 @@ class OpenLyricsExport(object):
|
|||||||
song.title)
|
song.title)
|
||||||
xml = openLyrics.song_to_xml(song)
|
xml = openLyrics.song_to_xml(song)
|
||||||
tree = etree.ElementTree(etree.fromstring(xml))
|
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]))
|
u', '.join([author.display_name for author in song.authors]))
|
||||||
filename = re.sub(
|
filename = re.sub(
|
||||||
r'[/\\?*|<>\[\]":<>+%]+', u'_', filename).strip(u'_')
|
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
|
# Pass a file object, because lxml does not cope with some special
|
||||||
# characters in the path (see lp:757673 and lp:744337).
|
# characters in the path (see lp:757673 and lp:744337).
|
||||||
tree.write(open(os.path.join(self.save_path, filename), u'w'),
|
tree.write(open(os.path.join(self.save_path, filename), u'w'),
|
||||||
|
Loading…
Reference in New Issue
Block a user