Setlist generating script added
and gitignore
This commit is contained in:
parent
8d50d6efca
commit
4625770a04
2 changed files with 115 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
ly
|
||||
*.pyc
|
||||
__pycache__
|
112
generate_list.py
Executable file
112
generate_list.py
Executable file
|
@ -0,0 +1,112 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# Combine sets and tunes into TeXable setlist
|
||||
# endproduct should look somewhat like example.tex
|
||||
from tunes_db.tune import Tune
|
||||
from tunes_db.sets import sets
|
||||
from tunes_db.tunes import tunes
|
||||
|
||||
import re
|
||||
|
||||
|
||||
heading = """
|
||||
\\newcommand{\\tunesep}{ - }
|
||||
\\newcommand{\\amountofcols}{6}
|
||||
\\newcommand{\seventeen}[1]{\\textit{#1}}
|
||||
\\newcommand{\\noscore}{ - }
|
||||
|
||||
\\begin{table}[h!]
|
||||
\\centering
|
||||
\\begin{adjustbox}{max width=\\textwidth}
|
||||
\\begin{tabular}{| r | l
|
||||
| l %pipes
|
||||
| l %bass
|
||||
| l %tenor
|
||||
| l %side
|
||||
|}
|
||||
\\multicolumn{\\amountofcols}{c}{ \\textbf{setlist 2017 seaforth highlanders of holland }}
|
||||
\\\\
|
||||
|
||||
\\hline
|
||||
set & titel
|
||||
& pipes %Pipes
|
||||
& bass %Bass
|
||||
& tenor %Tenor
|
||||
& snare %Side
|
||||
\\\\%"""
|
||||
|
||||
end = """\end{tabular}
|
||||
\end{adjustbox}
|
||||
\end{table}"""
|
||||
|
||||
def setlist_line_score(scorelist, instrument):
|
||||
# No Score set
|
||||
# Using scorelist = "", we can get empty lines
|
||||
if not scorelist and scorelist != "" :
|
||||
return '\\noscore{}'
|
||||
|
||||
tex_scorelist = ""
|
||||
for score in scorelist:
|
||||
if re.match('std\d\d', score):
|
||||
number = score.replace('std','')
|
||||
# This is a standard, we point to the instruments standard
|
||||
if instrument == "side":
|
||||
if number == "24" or number == "44":
|
||||
tex_scorelist += "\\hyperref[standards-24-44-standards.side]{Std. "+ number[0] + '/' + number[1] + "}"
|
||||
continue
|
||||
elif number == "34":
|
||||
tex_scorelist += "\\hyperref[standards-34-standards.side]{Std. "+ number[0] + '/' + number[1] + "}"
|
||||
continue
|
||||
elif number == "68":
|
||||
tex_scorelist += "\\hyperref[standards-68-standards.side]{Std. "+ number[0] + '/' + number[1] + "}"
|
||||
continue
|
||||
elif number == "98":
|
||||
tex_scorelist += "\\hyperref[standards-98-standards.side]{Std. "+ number[0] + '/' + number[1] + "}"
|
||||
continue
|
||||
elif instrument == "bass":
|
||||
tex_scorelist += "\\hyperref[standards-standards.bass]{Std. "+ number[0] + '/' + number[1] + "}"
|
||||
continue
|
||||
elif instrument == "tenor":
|
||||
tex_scorelist += "\\hyperref[standards-standards.tenor]{Std. "+ number[0] + '/' + number[1] + "}"
|
||||
continue
|
||||
|
||||
tex_scorelist += "\\pageref{" + score.replace('/','-') + "}"
|
||||
|
||||
return tex_scorelist
|
||||
|
||||
def setlist_line(prefix, title, pipes, bass, tenor, side):
|
||||
pipes = setlist_line_score(pipes, 'pipes')
|
||||
bass = setlist_line_score(bass, 'bass')
|
||||
tenor = setlist_line_score(tenor, 'tenor')
|
||||
side = setlist_line_score(side, 'side')
|
||||
|
||||
return "{prefix}\t& {title}\n\t& {pipes} %Pipes\n\t& {bass} %Bass\n\t& {tenor} %Tenor\n\t& {side} %Side\n\\\\ %".format(prefix = prefix, title = title, pipes = pipes, bass = bass, tenor = tenor, side = side)
|
||||
|
||||
|
||||
# 1 & 4/4 \hyperref[4-4-marches-bonnie-galloway-pipes]{Bonnie Galloway}\tunesep\hyperref[4-4-marches-were-no-awa-tae-bide-awa-pipes]{We're No Awa Tae Bide Awa}
|
||||
# & \pageref{4-4-marches-bonnie-galloway-pipes}\tunesep\pageref{4-4-marches-were-no-awa-tae-bide-awa-pipes}%Pipes
|
||||
# & \hyperref[standards-standards.bass]{Std. 4/4}%Bass
|
||||
# & \hyperref[standards-standards.tenor]{Std. 4/4}%Tenor
|
||||
# & \hyperref[standards-24-44-standards.side]{Std. 4/4}%Side
|
||||
#\\ %
|
||||
|
||||
print(heading)
|
||||
print("\\hline")
|
||||
for count, tuneset in enumerate(sets):
|
||||
if count % 5 == 0 and count != 0:
|
||||
print(setlist_line("","","","","",""))
|
||||
|
||||
print(setlist_line(tuneset.setid, tuneset.name, **tuneset.instruments))
|
||||
|
||||
print("""\\hline
|
||||
|
||||
\\multicolumn{\\amountofcols}{|c|}{Losse Nummers}\\\\%
|
||||
|
||||
\\hline""")
|
||||
|
||||
for count, tune in enumerate(tunes):
|
||||
if count % 5 == 0 and count != 0:
|
||||
print(setlist_line("","","","","",''))
|
||||
print(setlist_line("", tune.name, **tune.instruments))
|
||||
|
||||
print(end)
|
Loading…
Reference in a new issue