|
@ -5,6 +5,7 @@ |
|
|
|
|
|
|
|
|
import codecs |
|
|
import codecs |
|
|
import glob |
|
|
import glob |
|
|
|
|
|
import logging |
|
|
import os.path |
|
|
import os.path |
|
|
import re |
|
|
import re |
|
|
from subprocess import Popen, PIPE, call |
|
|
from subprocess import Popen, PIPE, call |
|
@ -16,6 +17,7 @@ from songbook_core.index import process_sxd |
|
|
from songbook_core.songs import Song, SongsList |
|
|
from songbook_core.songs import Song, SongsList |
|
|
from songbook_core.templates import TexRenderer |
|
|
from songbook_core.templates import TexRenderer |
|
|
|
|
|
|
|
|
|
|
|
LOGGER = logging.getLogger(__name__) |
|
|
EOL = "\n" |
|
|
EOL = "\n" |
|
|
DEFAULT_AUTHWORDS = { |
|
|
DEFAULT_AUTHWORDS = { |
|
|
"after": ["by"], |
|
|
"after": ["by"], |
|
@ -152,13 +154,11 @@ class SongbookBuilder(object): |
|
|
# are function; values are return values of functions. |
|
|
# are function; values are return values of functions. |
|
|
_called_functions = {} |
|
|
_called_functions = {} |
|
|
|
|
|
|
|
|
def __init__(self, raw_songbook, basename, logger=None): |
|
|
def __init__(self, raw_songbook, basename): |
|
|
# Representation of the .sb songbook configuration file. |
|
|
# Representation of the .sb songbook configuration file. |
|
|
self.songbook = Songbook(raw_songbook, basename) |
|
|
self.songbook = Songbook(raw_songbook, basename) |
|
|
# Basename of the songbook to be built. |
|
|
# Basename of the songbook to be built. |
|
|
self.basename = basename |
|
|
self.basename = basename |
|
|
# logging object to use |
|
|
|
|
|
self.logger = logger |
|
|
|
|
|
|
|
|
|
|
|
def _run_once(self, function, *args, **kwargs): |
|
|
def _run_once(self, function, *args, **kwargs): |
|
|
"""Run function if it has not been run yet. |
|
|
"""Run function if it has not been run yet. |
|
@ -237,7 +237,7 @@ class SongbookBuilder(object): |
|
|
while line: |
|
|
while line: |
|
|
log += line |
|
|
log += line |
|
|
line = p.stdout.readline() |
|
|
line = p.stdout.readline() |
|
|
self.logger.info(log) |
|
|
LOGGER.info(log) |
|
|
|
|
|
|
|
|
if p.returncode: |
|
|
if p.returncode: |
|
|
raise errors.LatexCompilationError(self.basename) |
|
|
raise errors.LatexCompilationError(self.basename) |
|
@ -246,8 +246,7 @@ class SongbookBuilder(object): |
|
|
"""Make index""" |
|
|
"""Make index""" |
|
|
sxd_files = glob.glob("%s_*.sxd" % self.basename) |
|
|
sxd_files = glob.glob("%s_*.sxd" % self.basename) |
|
|
for sxd_file in sxd_files: |
|
|
for sxd_file in sxd_files: |
|
|
if self.logger: |
|
|
LOGGER.info("processing " + sxd_file) |
|
|
self.logger.info("processing " + sxd_file) |
|
|
|
|
|
idx = process_sxd(sxd_file) |
|
|
idx = process_sxd(sxd_file) |
|
|
with open(sxd_file[:-3] + "sbx", "w") as index_file: |
|
|
with open(sxd_file[:-3] + "sbx", "w") as index_file: |
|
|
index_file.write(idx.entries_to_str().encode('utf8')) |
|
|
index_file.write(idx.entries_to_str().encode('utf8')) |
|
|