diff --git a/songbook/build.py b/songbook/build.py index e8ad8592..f4c16869 100644 --- a/songbook/build.py +++ b/songbook/build.py @@ -55,9 +55,9 @@ def formatDeclaration(name, parameter): def formatDefinition(name, value): return '\\set@{name}{{{value}}}\n'.format(name=name, value=value) -def makeTexFile(sb, library, output): +def makeTexFile(sb, library, output, core_dir): name = output[:-4] - + template_dir = core_dir+'templates/' # default value template = "patacrep.tmpl" songs = [] @@ -67,7 +67,7 @@ def makeTexFile(sb, library, output): authwords_tex = "" authwords = {"after": ["by"], "ignore": ["unknown"], "sep": ["and"]} - + # parse the songbook data if "template" in sb: template = sb["template"] @@ -111,7 +111,7 @@ def makeTexFile(sb, library, output): Song.prefixes = prefixes Song.authwords = authwords - parameters = parseTemplate("templates/"+template) + parameters = parseTemplate(template_dir+template) # compute songslist if songs == "all": @@ -142,15 +142,15 @@ def makeTexFile(sb, library, output): # output template commentPattern = re.compile(r"^\s*%") - f = open("templates/"+template) + f = open(template_dir+template) content = [ line for line in f if not commentPattern.match(line) ] for index, line in enumerate(content): if re.compile("getLibraryImgDirectory").search(line): - line = line.replace("\\getLibraryImgDirectory", library + "img/") + line = line.replace("\\getLibraryImgDirectory", core_dir + "img/") content[index] = line if re.compile("getLibraryLilypondDirectory").search(line): - line = line.replace("\\getLibraryLilypondDirectory", library + "lilypond/") + line = line.replace("\\getLibraryLilypondDirectory", core_dir + "lilypond/") content[index] = line f.close() @@ -168,12 +168,16 @@ def buildsongbook(sb, basename, library): - basename: basename of the songbook to be built. """ + MOD_DIR = os.path.dirname(os.path.abspath(__file__)) + CORE_DIR = MOD_DIR + '/../' + texFile = basename + ".tex" pdfFile = basename + ".pdf" # Make TeX file - makeTexFile(sb, library, texFile) - + makeTexFile(sb, library, texFile, CORE_DIR) + + os.environ['TEXMFHOME'] = MOD_DIR + '/../' # First pdflatex pass call(["pdflatex", texFile]) diff --git a/tex/chords.tex b/tex/latex/chords.tex similarity index 100% rename from tex/chords.tex rename to tex/latex/chords.tex diff --git a/tex/crepbook.cls b/tex/latex/crepbook.cls similarity index 100% rename from tex/crepbook.cls rename to tex/latex/crepbook.cls diff --git a/tex/licence.sty b/tex/latex/licence.sty similarity index 100% rename from tex/licence.sty rename to tex/latex/licence.sty diff --git a/tex/license-nb.tex b/tex/latex/license-nb.tex similarity index 100% rename from tex/license-nb.tex rename to tex/latex/license-nb.tex diff --git a/tex/license.tex b/tex/latex/license.tex similarity index 100% rename from tex/license.tex rename to tex/latex/license.tex diff --git a/tex/songs.sty b/tex/latex/songs.sty similarity index 100% rename from tex/songs.sty rename to tex/latex/songs.sty diff --git a/tex/venturisold.sty b/tex/latex/venturisold.sty similarity index 100% rename from tex/venturisold.sty rename to tex/latex/venturisold.sty diff --git a/tex/xstring.sty b/tex/latex/xstring.sty similarity index 100% rename from tex/xstring.sty rename to tex/latex/xstring.sty diff --git a/tex/xstring.tex b/tex/latex/xstring.tex similarity index 100% rename from tex/xstring.tex rename to tex/latex/xstring.tex