|
@ -57,9 +57,7 @@ class Songbook(object): |
|
|
'lang': 'english', |
|
|
'lang': 'english', |
|
|
'sort': [u"by", u"album", u"@title"], |
|
|
'sort': [u"by", u"album", u"@title"], |
|
|
'content': None, |
|
|
'content': None, |
|
|
'datadir': os.path.abspath('.'), |
|
|
|
|
|
} |
|
|
} |
|
|
self.songslist = None |
|
|
|
|
|
self._parse_raw(raw_songbook) |
|
|
self._parse_raw(raw_songbook) |
|
|
|
|
|
|
|
|
@staticmethod |
|
|
@staticmethod |
|
@ -94,7 +92,7 @@ class Songbook(object): |
|
|
are stored verbatim in self.config. |
|
|
are stored verbatim in self.config. |
|
|
""" |
|
|
""" |
|
|
self.config.update(raw_songbook) |
|
|
self.config.update(raw_songbook) |
|
|
self.config['datadir'] = os.path.abspath(self.config['datadir']) |
|
|
self._set_datadir() |
|
|
|
|
|
|
|
|
# Compute song list |
|
|
# Compute song list |
|
|
if self.config['content'] is None: |
|
|
if self.config['content'] is None: |
|
@ -102,11 +100,11 @@ class Songbook(object): |
|
|
"song", |
|
|
"song", |
|
|
os.path.relpath( |
|
|
os.path.relpath( |
|
|
filename, |
|
|
filename, |
|
|
os.path.join(self.config['datadir'], 'songs'), |
|
|
os.path.join(self.config['datadir'][0], 'songs'), |
|
|
)) |
|
|
)) |
|
|
for filename |
|
|
for filename |
|
|
in recursive_find( |
|
|
in recursive_find( |
|
|
os.path.join(self.config['datadir'], 'songs'), |
|
|
os.path.join(self.config['datadir'][0], 'songs'), |
|
|
'*.sg', |
|
|
'*.sg', |
|
|
) |
|
|
) |
|
|
] |
|
|
] |
|
@ -114,7 +112,7 @@ class Songbook(object): |
|
|
content = self.config["content"] |
|
|
content = self.config["content"] |
|
|
self.config["content"] = [] |
|
|
self.config["content"] = [] |
|
|
for elem in content: |
|
|
for elem in content: |
|
|
if isinstance(elem, str) or isinstance(elem, unicode): |
|
|
if isinstance(elem, basestring): |
|
|
self.config["content"].append(("song", elem)) |
|
|
self.config["content"].append(("song", elem)) |
|
|
elif isinstance(elem, list): |
|
|
elif isinstance(elem, list): |
|
|
self.config["content"].append((elem[0], elem[1])) |
|
|
self.config["content"].append((elem[0], elem[1])) |
|
@ -129,6 +127,25 @@ class Songbook(object): |
|
|
if key not in self.config['authwords']: |
|
|
if key not in self.config['authwords']: |
|
|
self.config['authwords'][key] = value |
|
|
self.config['authwords'][key] = value |
|
|
|
|
|
|
|
|
|
|
|
def _set_datadir(self): |
|
|
|
|
|
"""Set the default values for datadir""" |
|
|
|
|
|
try: |
|
|
|
|
|
if isinstance(self.config['datadir'], basestring): |
|
|
|
|
|
self.config['datadir'] = [self.config['datadir']] |
|
|
|
|
|
except KeyError: # No datadir in the raw_songbook |
|
|
|
|
|
self.config['datadir'] = [os.path.abspath('.')] |
|
|
|
|
|
|
|
|
|
|
|
abs_datadir = [] |
|
|
|
|
|
for path in self.config['datadir']: |
|
|
|
|
|
if os.path.exists(path) and os.path.isdir(path): |
|
|
|
|
|
abs_datadir.append(os.path.abspath(path)) |
|
|
|
|
|
else: |
|
|
|
|
|
LOGGER.warning("Ignoring non-existent datadir '{}'.".format(path)) |
|
|
|
|
|
|
|
|
|
|
|
abs_datadir.append(__DATADIR__) |
|
|
|
|
|
|
|
|
|
|
|
self.config['datadir'] = abs_datadir |
|
|
|
|
|
|
|
|
def _parse_songs(self): |
|
|
def _parse_songs(self): |
|
|
"""Parse content included in songbook.""" |
|
|
"""Parse content included in songbook.""" |
|
|
self.contentlist = SongbookContent(self.config['datadir']) |
|
|
self.contentlist = SongbookContent(self.config['datadir']) |
|
@ -186,18 +203,7 @@ class SongbookBuilder(object): |
|
|
return self._called_functions[function] |
|
|
return self._called_functions[function] |
|
|
|
|
|
|
|
|
def _set_latex(self): |
|
|
def _set_latex(self): |
|
|
"""Set TEXINPUTS and LaTeX options.""" |
|
|
"""Set LaTeX options.""" |
|
|
if not 'TEXINPUTS' in os.environ.keys(): |
|
|
|
|
|
os.environ['TEXINPUTS'] = '' |
|
|
|
|
|
os.environ['TEXINPUTS'] += os.pathsep + os.path.join( |
|
|
|
|
|
__DATADIR__, |
|
|
|
|
|
'latex', |
|
|
|
|
|
) |
|
|
|
|
|
os.environ['TEXINPUTS'] += os.pathsep + os.path.join( |
|
|
|
|
|
self.songbook.config['datadir'], |
|
|
|
|
|
'latex', |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
if self.unsafe: |
|
|
if self.unsafe: |
|
|
self._pdflatex_options.append("--shell-escape") |
|
|
self._pdflatex_options.append("--shell-escape") |
|
|
if not self.interactive: |
|
|
if not self.interactive: |
|
|