Browse Source

fix typos; add replace cases; handle spaces in strings

remotes/origin/cmake
Romain Goffe 13 years ago
parent
commit
474cb72c35
  1. 4
      songbook.py
  2. 22
      title_sort.py

4
songbook.py

@ -8,7 +8,7 @@ import glob
import re
import json
import locale
import titlesort
import title_sort
def matchRegexp(reg, iterable):
return [ m.group(1) for m in (reg.match(l) for l in iterable) if m ]
@ -96,8 +96,8 @@ def makeTexFile(sb, output):
# output songslist
if songs == "all":
songs = map(lambda x: x[6:], glob.glob('songs/*/*.sg'))
songs.sort(key=title_sort.sortkey)
songs.sort(key=title_sort.sortkey)
if len(songs) > 0:
out.write(formatDefinition('songslist', songslist(songs)))
out.write('\\makeatother\n')

22
title_sort.py

@ -7,10 +7,22 @@ import locale
iecPattern = re.compile(r"\IeC {\\(.*?)}")
replacePattern = {
'`A': 'À',
'oe ': 'œ',
'`a': 'à',
'^a': 'â',
'oe': 'œ',
"'e" : 'é',
"`e" : 'è',
"^e" : 'ê',
'"e' : 'ë',
"'E" : 'É',
"`E" : 'È',
"'o" : 'ó',
"c C" : 'ç',
"^o" : 'ô',
r'"\i' : 'i',
r'^\i' : 'i',
'"u' : 'ü',
"c C" : 'Ç',
"c c" : 'ç',
}
def sortkey(value):
@ -22,8 +34,8 @@ def sortkey(value):
'''
def repl(match):
try:
return replacePattern[match.group(1)]
return replacePattern[match.group(1).strip()]
except KeyError:
warnings.warn("Error, no match to replace %s in %s. You should add it in the coresponding table in title_solt.py" % (match.group(0), match.group(1)))
warnings.warn("Error, no match to replace %s in %s. You should add it in the coresponding table in title_sort.py" % (match.group(0), match.group(1)))
return locale.strxfrm(iecPattern.sub(repl, value))
return locale.strxfrm(iecPattern.sub(repl, value).replace(' ', 'A'))

Loading…
Cancel
Save