Browse Source

Support Debian stable python version 2.5 (at least)

Support str.format() (new in 2.6) as well as % (modulo) operator for string formatting. This enhances the compatibility of the script with earlier version of python (such as python 2.5 which is the current Debian's python interpreter).
remotes/origin/translate_notes
Alexandre Dupas 15 years ago
parent
commit
2b8876d824
  1. 19
      songbook-volume.py

19
songbook-volume.py

@ -11,11 +11,20 @@ def formatSongsDatabase( file, songs ):
dir = ['img']+map(os.path.dirname, songs)
dir = set( dir )
sdb.write('\graphicspath{\n')
for dirname in dir:
sdb.write(' {{{imagedir}/}},\n'.format(imagedir=dirname))
sdb.write('}\n')
for song in songs:
sdb.write('\input{{{songfile}}}\n'.format(songfile=song.strip()))
if sys.hexversion >= 0x20600000:
# use string format introduced in python 2.6
for dirname in dir:
sdb.write(' {{{imagedir}/}},\n'.format(imagedir=dirname))
sdb.write('}\n')
for song in songs:
sdb.write('\input{{{songfile}}}\n'.format(songfile=song.strip()))
else:
# use old formating strategy
for dirname in dir:
sdb.write(' {%(imagedir)s/},\n' % {'imagedir':dirname})
sdb.write('}\n')
for song in songs:
sdb.write('\input{%(songfile)s}\n' % {'songfile':song.strip()})
sdb.close();

Loading…
Cancel
Save