The lytex file now gets assembled with the help of a python script. because I can!
This commit is contained in:
parent
f2f8b493b9
commit
ffe0102369
5
Makefile
5
Makefile
@ -1,6 +1,6 @@
|
||||
OUTDIR=out
|
||||
PDFDIR=pdf
|
||||
FILE = music_booklet
|
||||
FILE = singalongs
|
||||
GITINFO=revision.tex
|
||||
LILY_PDF = lilypond-book --process="lilypond -dinclude-settings=lilysettings.ly" --pdf -o $(OUTDIR)
|
||||
PDF=cd $(OUTDIR) && pdflatex --enable-pipes --shell-escape $(FILE).tex
|
||||
@ -17,13 +17,14 @@ VPATH = \
|
||||
all: book booklet
|
||||
|
||||
book: $(OUTDIR) $(PDFDIR) $(GITINFO)
|
||||
python assemble.py > $(OUTDIR)/$(FILE).lytex
|
||||
cp lilysettings.ly $(OUTDIR)/
|
||||
cp headfoot.tex $(OUTDIR)/
|
||||
cp settings.tex $(OUTDIR)/
|
||||
cp -r license/ $(OUTDIR)/
|
||||
cp -r images/ $(OUTDIR)/
|
||||
cp $(GITINFO) $(OUTDIR)/
|
||||
$(LILY_PDF) $(FILE).lytex
|
||||
$(LILY_PDF) $(OUTDIR)/$(FILE).lytex
|
||||
$(PDF)
|
||||
$(INDEX)
|
||||
$(PDF)
|
||||
|
72
assemble.py
Normal file
72
assemble.py
Normal file
@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
lily_template = """
|
||||
\chapter {[[title]]}
|
||||
\lilypondfile{[[scorefile]]}
|
||||
~\\ ~\\
|
||||
\input{[[lyricfile]]}
|
||||
"""
|
||||
|
||||
def find_ly_files(path='./scores'):
|
||||
lilyfiles = []
|
||||
for found_file in os.listdir(path):
|
||||
if found_file.endswith(".ly"):
|
||||
filepath = os.path.join(path, found_file)
|
||||
lilyfiles.append(filepath)
|
||||
|
||||
return lilyfiles
|
||||
|
||||
def build_songmap(lilyfiles, lyric_folder='./lyrics'):
|
||||
songmap = []
|
||||
for scorefile in lilyfiles:
|
||||
filename_with_ext = os.path.basename(scorefile)
|
||||
filename = os.path.splitext(filename_with_ext)[0]
|
||||
lyricfile = os.path.join(lyric_folder, "{0}.tex".format(filename))
|
||||
|
||||
title = find_title(scorefile)
|
||||
|
||||
songmap.append({'scorefile': scorefile, 'lyricfile': lyricfile, 'title': title })
|
||||
|
||||
return songmap
|
||||
|
||||
def find_title(scorefile):
|
||||
with open(scorefile) as opened_file:
|
||||
score = opened_file.read()
|
||||
title = re.findall('title = "(.*)"', score)
|
||||
|
||||
return title[0]
|
||||
|
||||
def build_lytex(base_template, songmap):
|
||||
lilychapters = []
|
||||
for song in sorted(songmap, key=lambda k: k['scorefile']):
|
||||
lilychapter = lily_template.replace('[[title]]', song['title'])
|
||||
lilychapter = lilychapter.replace('[[scorefile]]', song['scorefile'])
|
||||
lilychapter = lilychapter.replace('[[lyricfile]]', song['lyricfile'])
|
||||
|
||||
lilychapters.append(lilychapter)
|
||||
|
||||
lilychapters_string = create_lilychapter_string(lilychapters)
|
||||
|
||||
with open(base_template) as opened_file:
|
||||
template = opened_file.read()
|
||||
template = template.replace('\\musicbooklet', lilychapters_string)
|
||||
|
||||
return template
|
||||
|
||||
def create_lilychapter_string(lilychapters):
|
||||
lilychapter_string = ''
|
||||
for lilychapter in lilychapters:
|
||||
lilychapter_string += '{0}\n'.format(lilychapter)
|
||||
|
||||
return lilychapter_string
|
||||
|
||||
lilyfiles = find_ly_files()
|
||||
songmap = build_songmap(lilyfiles)
|
||||
lytex_source = build_lytex('singalongs.tex', songmap)
|
||||
|
||||
print(lytex_source)
|
||||
|
@ -1,154 +0,0 @@
|
||||
% This document is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% This document is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with this document. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\documentclass[12pt, a4paper, openany]{scrbook}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage{graphicx}
|
||||
\usepackage{fancyhdr}
|
||||
\usepackage{geometry}
|
||||
\usepackage{xmpincl}
|
||||
\usepackage{hyperref}
|
||||
|
||||
\input{revision.tex}
|
||||
\input{settings.tex}
|
||||
\input{headfoot.tex}
|
||||
|
||||
\renewcommand*\rmdefault{iwona}\normalfont\upshape
|
||||
|
||||
\begin{document}
|
||||
\widowpenalties 1 10000
|
||||
\raggedbottom
|
||||
\pagenumbering{roman}
|
||||
|
||||
\input{title.tex}
|
||||
|
||||
\chapter*{Contributors}
|
||||
\begin{itemize}
|
||||
\item Matias Hugentobler
|
||||
\item Sebastian Hugentobler
|
||||
\end{itemize}
|
||||
|
||||
\tableofcontents
|
||||
|
||||
\clearpage
|
||||
|
||||
\pagenumbering{arabic}
|
||||
|
||||
\chapter{All for Me Grog}
|
||||
\lilypondfile{notes/AllForMeGrog.ly}
|
||||
~\\ ~\\
|
||||
\input{lyrics/AllForMeGrog.tex}
|
||||
|
||||
\chapter{Auld Lang Syne}
|
||||
\lilypondfile{notes/AuldLangSyne.ly}
|
||||
~\\ ~\\
|
||||
\input{lyrics/AuldLangSyne.tex}
|
||||
|
||||
\chapter{The Black Velvet Band}
|
||||
\lilypondfile{notes/BlackVelvetBand.ly}
|
||||
~\\ ~\\
|
||||
\input{lyrics/BlackVelvetBand.tex}
|
||||
|
||||
\chapter{Bürgerlied}
|
||||
\lilypondfile{notes/Buergerlied.ly}
|
||||
~\\ ~\\
|
||||
\input{lyrics/Buergerlied.tex}
|
||||
|
||||
\chapter {Drunken Sailor}
|
||||
\lilypondfile{notes/DrunkenSailor.ly}
|
||||
~\\ ~\\
|
||||
\input{lyrics/DrunkenSailor.tex}
|
||||
|
||||
\chapter{Finnegan's Wake}
|
||||
\lilypondfile{notes/FinnegansWake.ly}
|
||||
~\\ ~\\
|
||||
\input{lyrics/FinnegansWake.tex}
|
||||
|
||||
\chapter{The Foggy Dew}
|
||||
\lilypondfile{notes/FoggyDew.ly}
|
||||
~\\ ~\\
|
||||
\input{lyrics/FoggyDew.tex}
|
||||
|
||||
\chapter{I'm a Rover Seldom Sober}
|
||||
\lilypondfile{notes/ImARoverSeldomSober.ly}
|
||||
~\\ ~\\
|
||||
\input{lyrics/ImARoverSeldomSober.tex}
|
||||
|
||||
\chapter{The Irish Rover}
|
||||
\lilypondfile{notes/IrishRover.ly}
|
||||
~\\ ~\\
|
||||
\input{lyrics/IrishRover.tex}
|
||||
|
||||
\chapter{Johnny I Hardly Knew Ye}
|
||||
\lilypondfile{notes/JohnnyIHardlyKnewYe.ly}
|
||||
~\\ ~\\
|
||||
\input{lyrics/JohnnyIHardlyKnewYe.tex}
|
||||
|
||||
\chapter{The Kerry Recruit}
|
||||
\lilypondfile{notes/KerryRecruit.ly}
|
||||
~\\ ~\\
|
||||
\input{lyrics/KerryRecruit.tex}
|
||||
|
||||
\chapter{MacPherson's Farewell}
|
||||
\lilypondfile{notes/MacPhersonsFarewell.ly}
|
||||
~\\ ~\\
|
||||
\input{lyrics/MacPhersonsFarewell.tex}
|
||||
|
||||
\chapter{Molly Malone}
|
||||
\lilypondfile{notes/MollyMalone.ly}
|
||||
~\\ ~\\
|
||||
\input{lyrics/MollyMalone.tex}
|
||||
|
||||
\chapter{Muirsheen Durkin}
|
||||
\lilypondfile{notes/MuirsheenDurkin.ly}
|
||||
~\\ ~\\
|
||||
\input{lyrics/MuirsheenDurkin.tex}
|
||||
|
||||
\chapter {A Nation Once Again}
|
||||
\lilypondfile{notes/NationOnceAgain.ly}
|
||||
~\\ ~\\
|
||||
\input{lyrics/NationOnceAgain.tex}
|
||||
|
||||
\chapter{The Parting Glass}
|
||||
\lilypondfile{notes/PartingGlass.ly}
|
||||
~\\ ~\\
|
||||
\input{lyrics/PartingGlass.tex}
|
||||
|
||||
\chapter {The Rising of the Moon}
|
||||
\lilypondfile{notes/RisingOfTheMoon.ly}
|
||||
~\\ ~\\
|
||||
\input{lyrics/RisingOfTheMoon.tex}
|
||||
|
||||
\chapter{Spancil Hill}
|
||||
\lilypondfile{notes/SpancilHill.ly}
|
||||
~\\ ~\\
|
||||
\input{lyrics/SpancilHill.tex}
|
||||
|
||||
\chapter{The Star of the County Down}
|
||||
\lilypondfile{notes/StarOfTheCountyDown.ly}
|
||||
~\\ ~\\
|
||||
\input{lyrics/StarOfTheCountyDown.tex}
|
||||
|
||||
\chapter{Whiskey in the Jar}
|
||||
\lilypondfile{notes/WhiskeyInTheJar.ly}
|
||||
~\\ ~\\
|
||||
\input{lyrics/WhiskeyInTheJar.tex}
|
||||
|
||||
\chapter{The Wild Rover}
|
||||
\lilypondfile{notes/WildRover.ly}
|
||||
~\\ ~\\
|
||||
\input{lyrics/WildRover.tex}
|
||||
|
||||
\end{document}
|
||||
|
51
singalongs.tex
Normal file
51
singalongs.tex
Normal file
@ -0,0 +1,51 @@
|
||||
% This document is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% This document is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with this document. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\documentclass[12pt, a4paper, openany]{scrbook}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage{graphicx}
|
||||
\usepackage{fancyhdr}
|
||||
\usepackage{geometry}
|
||||
\usepackage{xmpincl}
|
||||
\usepackage{hyperref}
|
||||
|
||||
\input{revision.tex}
|
||||
\input{settings.tex}
|
||||
\input{headfoot.tex}
|
||||
|
||||
\renewcommand*\rmdefault{iwona}\normalfont\upshape
|
||||
|
||||
\begin{document}
|
||||
\widowpenalties 1 10000
|
||||
\raggedbottom
|
||||
\pagenumbering{roman}
|
||||
|
||||
\input{title.tex}
|
||||
|
||||
\chapter*{Contributors}
|
||||
\begin{itemize}
|
||||
\item Matias Hugentobler
|
||||
\item Sebastian Hugentobler
|
||||
\end{itemize}
|
||||
|
||||
\tableofcontents
|
||||
|
||||
\clearpage
|
||||
|
||||
\pagenumbering{arabic}
|
||||
|
||||
\musicbooklet
|
||||
|
||||
\end{document}
|
||||
|
Loading…
Reference in New Issue
Block a user