|
@ -9,10 +9,9 @@ import yaml |
|
|
|
|
|
|
|
|
from pkg_resources import resource_filename |
|
|
from pkg_resources import resource_filename |
|
|
|
|
|
|
|
|
from patacrep.songs import DataSubpath |
|
|
|
|
|
from patacrep import content, files |
|
|
from patacrep import content, files |
|
|
from patacrep.content import song, section, songsection, tex |
|
|
from patacrep.content import song, section, songsection, tex |
|
|
from patacrep.build import config_model |
|
|
from patacrep.songbook import prepare_songbook |
|
|
|
|
|
|
|
|
from .. import logging_reduced |
|
|
from .. import logging_reduced |
|
|
from .. import dynamic # pylint: disable=unused-import |
|
|
from .. import dynamic # pylint: disable=unused-import |
|
@ -28,10 +27,6 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): |
|
|
maxDiff = None |
|
|
maxDiff = None |
|
|
config = None |
|
|
config = None |
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
|
def setUpClass(cls): |
|
|
|
|
|
cls._generate_config() |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
@classmethod |
|
|
def _iter_testmethods(cls): |
|
|
def _iter_testmethods(cls): |
|
|
"""Iterate over dynamically generated test methods""" |
|
|
"""Iterate over dynamically generated test methods""" |
|
@ -55,8 +50,9 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): |
|
|
with open(sourcename, mode="r", encoding="utf8") as sourcefile: |
|
|
with open(sourcename, mode="r", encoding="utf8") as sourcefile: |
|
|
sbcontent = yaml.load(sourcefile) |
|
|
sbcontent = yaml.load(sourcefile) |
|
|
|
|
|
|
|
|
config = cls.config.copy() |
|
|
outputdir = os.path.dirname(base) |
|
|
config['_outputdir'] = os.path.dirname(base) |
|
|
config = cls._generate_config(sbcontent, outputdir, base) |
|
|
|
|
|
|
|
|
with logging_reduced('patacrep.content.song'): |
|
|
with logging_reduced('patacrep.content.song'): |
|
|
expandedlist = content.process_content(sbcontent, config) |
|
|
expandedlist = content.process_content(sbcontent, config) |
|
|
sourcelist = [cls._clean_path(elem) for elem in expandedlist] |
|
|
sourcelist = [cls._clean_path(elem) for elem in expandedlist] |
|
@ -97,28 +93,27 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): |
|
|
raise Exception(elem) |
|
|
raise Exception(elem) |
|
|
|
|
|
|
|
|
@classmethod |
|
|
@classmethod |
|
|
def _generate_config(cls): |
|
|
def _generate_config(cls, sbcontent, outputdir, base): |
|
|
"""Generate the config to process the content""" |
|
|
"""Generate the config to process the content""" |
|
|
|
|
|
|
|
|
# Load the default songbook config |
|
|
# Load the default songbook config |
|
|
config = config_model('default')['en'] |
|
|
config = prepare_songbook( |
|
|
|
|
|
{'book':{'datadir':'datadir'}, 'content': sbcontent}, |
|
|
datadirpaths = [os.path.join(os.path.dirname(__file__), 'datadir')] |
|
|
outputdir, |
|
|
|
|
|
base, |
|
|
config['_datadir'] = datadirpaths |
|
|
outputdir |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
config['_songdir'] = [ |
|
|
# Load the plugins |
|
|
DataSubpath(path, 'songs') |
|
|
|
|
|
for path in datadirpaths |
|
|
|
|
|
] |
|
|
|
|
|
config['_content_plugins'] = files.load_plugins( |
|
|
config['_content_plugins'] = files.load_plugins( |
|
|
datadirs=datadirpaths, |
|
|
datadirs=config['_datadir'], |
|
|
root_modules=['content'], |
|
|
root_modules=['content'], |
|
|
keyword='CONTENT_PLUGINS', |
|
|
keyword='CONTENT_PLUGINS', |
|
|
) |
|
|
) |
|
|
config['_song_plugins'] = files.load_plugins( |
|
|
config['_song_plugins'] = files.load_plugins( |
|
|
datadirs=datadirpaths, |
|
|
datadirs=config['_datadir'], |
|
|
root_modules=['songs'], |
|
|
root_modules=['songs'], |
|
|
keyword='SONG_RENDERERS', |
|
|
keyword='SONG_RENDERERS', |
|
|
)['tsg'] |
|
|
)['tsg'] |
|
|
cls.config = config |
|
|
|
|
|
|
|
|
return config |
|
|