From 5a89a4a8743b6d763a110ccabdfb72d79964e7c7 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Sun, 12 Jun 2016 22:25:00 +0200 Subject: [PATCH] Better function names --- patacrep/content/__init__.py | 2 +- patacrep/content/song.py | 2 +- patacrep/files.py | 4 ++-- patacrep/tools/convert/__main__.py | 2 +- test/test_song/test_parser.py | 12 ++++-------- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/patacrep/content/__init__.py b/patacrep/content/__init__.py index 9b0655af..eaaeaa59 100755 --- a/patacrep/content/__init__.py +++ b/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): diff --git a/patacrep/content/song.py b/patacrep/content/song.py index 074ae394..3063a700 100755 --- a/patacrep/content/song.py +++ b/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() diff --git a/patacrep/files.py b/patacrep/files.py index bad0f90f..1ad296d5 100644 --- a/patacrep/files.py +++ b/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), diff --git a/patacrep/tools/convert/__main__.py b/patacrep/tools/convert/__main__.py index ac6c0843..3916b6ae 100644 --- a/patacrep/tools/convert/__main__.py +++ b/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( diff --git a/test/test_song/test_parser.py b/test/test_song/test_parser.py index e4c0da35..6123470a 100644 --- a/test/test_song/test_parser.py +++ b/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__ = (