Browse Source

Better function names

pull/227/head
Oliverpool 9 years ago
parent
commit
5a89a4a874
  1. 2
      patacrep/content/__init__.py
  2. 2
      patacrep/content/song.py
  3. 4
      patacrep/files.py
  4. 2
      patacrep/tools/convert/__main__.py
  5. 12
      test/test_song/test_parser.py

2
patacrep/content/__init__.py

@ -259,7 +259,7 @@ def process_content(content, config=None):
included in the .tex file.
"""
contentlist = ContentList()
plugins = files.load_plugins_content(config['_datadir'])
plugins = files.load_content_plugins(config['_datadir'])
if not content:
content = [{'song': None}]
elif isinstance(content, dict):

2
patacrep/content/song.py

@ -87,7 +87,7 @@ def parse(keyword, argument, config):
contentlist = argument
if isinstance(contentlist, str):
contentlist = [contentlist]
plugins = files.load_plugins_songs(config['_datadir'])['tsg']
plugins = files.load_renderer_plugins(config['_datadir'])['tsg']
if '_langs' not in config:
config['_langs'] = set()
songlist = ContentList()

4
patacrep/files.py

@ -94,7 +94,7 @@ def iter_modules(path, prefix):
LOGGER.debug("[plugins] Could not load module {}: {}".format(name, str(error)))
continue
def load_plugins_content(datadirs=()):
def load_content_plugins(datadirs=()):
"""Load the content plugins, and return a dictionary of those plugins."""
return load_plugins(
datadirs=tuple(datadirs),
@ -102,7 +102,7 @@ def load_plugins_content(datadirs=()):
keyword='CONTENT_PLUGINS',
)
def load_plugins_songs(datadirs=()):
def load_renderer_plugins(datadirs=()):
"""Load the song renderer plugins, and return a dictionary of those plugins."""
return load_plugins(
datadirs=tuple(datadirs),

2
patacrep/tools/convert/__main__.py

@ -35,7 +35,7 @@ def main(args=None):
dest = args[2]
song_files = args[3:]
renderers = files.load_plugins_songs()
renderers = files.load_renderer_plugins()
if dest not in renderers:
LOGGER.error(

12
test/test_song/test_parser.py

@ -60,7 +60,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
with self.chdir():
with open_read(destname) as expectfile:
with logging_reduced():
song = self.song_plugins[out_format][in_format](sourcename, self.config)
song = self.song_renderer[out_format][in_format](sourcename, self.config)
expected = expectfile.read().strip().replace(
"@TEST_FOLDER@",
files.path2posix(resource_filename(__name__, "")),
@ -76,14 +76,10 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
# Setting datadir
# Load the default songbook config
cls.config = config_model('default')['en']
cls.config['_datadir'] = ['datadir']
if '_datadir' not in cls.config:
cls.config['_datadir'] = []
cls.config['_datadir'].append('datadir')
cls.song_renderer = files.load_renderer_plugins()
cls.song_plugins = files.load_plugins_songs(
datadirs=cls.config['_datadir'],
)
with cls.chdir():
for source in sorted(glob.glob('*.*.source')):
[*base, in_format, _] = source.split('.')
@ -126,7 +122,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
"""Test that `base` parsing fails."""
sourcename = "{}.{}.source".format(base, in_format)
with self.chdir('errors'):
parser = self.song_plugins[out_format][in_format]
parser = self.song_renderer[out_format][in_format]
self.assertRaises(errors.SongSyntaxError, parser, sourcename, self.config)
test_parse_failure.__doc__ = (

Loading…
Cancel
Save