|
@ -49,7 +49,17 @@ def makeCoverCache(library): |
|
|
def matchRegexp(reg, iterable): |
|
|
def matchRegexp(reg, iterable): |
|
|
return [ m.group(1) for m in (reg.match(l) for l in iterable) if m ] |
|
|
return [ m.group(1) for m in (reg.match(l) for l in iterable) if m ] |
|
|
|
|
|
|
|
|
def songslist(library, songs): |
|
|
def unprefixed(title, prefixes): |
|
|
|
|
|
"""Remove the first prefix of the list in the beginning of title (if any). |
|
|
|
|
|
""" |
|
|
|
|
|
for prefix in prefixes: |
|
|
|
|
|
match = re.compile(r"^(%s)\b\s*(.*)$" % prefix).match(title) |
|
|
|
|
|
if match: |
|
|
|
|
|
return match.group(2) |
|
|
|
|
|
return title |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def songslist(library, songs, prefixes): |
|
|
song_objects = [] |
|
|
song_objects = [] |
|
|
for s in songs: |
|
|
for s in songs: |
|
|
path = library + 'songs/' + s |
|
|
path = library + 'songs/' + s |
|
@ -64,7 +74,7 @@ def songslist(library, songs): |
|
|
album = '' |
|
|
album = '' |
|
|
song_objects.append(Song(title, artist, album, path)) |
|
|
song_objects.append(Song(title, artist, album, path)) |
|
|
|
|
|
|
|
|
song_objects = sorted(song_objects, key=lambda x: locale.strxfrm(x.title)) |
|
|
song_objects = sorted(song_objects, key=lambda x: locale.strxfrm(unprefixed(x.title, prefixes))) |
|
|
song_objects = sorted(song_objects, key=lambda x: locale.strxfrm(x.album)) |
|
|
song_objects = sorted(song_objects, key=lambda x: locale.strxfrm(x.album)) |
|
|
song_objects = sorted(song_objects, key=lambda x: locale.strxfrm(x.artist)) |
|
|
song_objects = sorted(song_objects, key=lambda x: locale.strxfrm(x.artist)) |
|
|
|
|
|
|
|
@ -121,6 +131,8 @@ def makeTexFile(sb, library, output): |
|
|
# default value |
|
|
# default value |
|
|
template = "patacrep.tmpl" |
|
|
template = "patacrep.tmpl" |
|
|
songs = [] |
|
|
songs = [] |
|
|
|
|
|
titleprefixwords = "" |
|
|
|
|
|
prefixes = [] |
|
|
|
|
|
|
|
|
# parse the songbook data |
|
|
# parse the songbook data |
|
|
if "template" in sb: |
|
|
if "template" in sb: |
|
@ -129,6 +141,12 @@ def makeTexFile(sb, library, output): |
|
|
if "songs" in sb: |
|
|
if "songs" in sb: |
|
|
songs = sb["songs"] |
|
|
songs = sb["songs"] |
|
|
del sb["songs"] |
|
|
del sb["songs"] |
|
|
|
|
|
if "titleprefixwords" in sb: |
|
|
|
|
|
prefixes = sb["titleprefixwords"] |
|
|
|
|
|
for prefix in sb["titleprefixwords"]: |
|
|
|
|
|
titleprefixwords += "\\titleprefixword{%s}\n" % prefix |
|
|
|
|
|
sb["titleprefixwords"] = titleprefixwords |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parameters = parseTemplate("templates/"+template) |
|
|
parameters = parseTemplate("templates/"+template) |
|
|
|
|
|
|
|
@ -151,7 +169,7 @@ def makeTexFile(sb, library, output): |
|
|
songs = map(lambda x: x[len(library) + 6:], glob.glob(library + 'songs/*/*.sg')) |
|
|
songs = map(lambda x: x[len(library) + 6:], glob.glob(library + 'songs/*/*.sg')) |
|
|
|
|
|
|
|
|
if len(songs) > 0: |
|
|
if len(songs) > 0: |
|
|
out.write(formatDefinition('songslist', songslist(library, songs))) |
|
|
out.write(formatDefinition('songslist', songslist(library, songs, prefixes))) |
|
|
out.write('\\makeatother\n') |
|
|
out.write('\\makeatother\n') |
|
|
|
|
|
|
|
|
# output template |
|
|
# output template |
|
|