diff --git a/patacrep/authors.py b/patacrep/authors.py index 12715ed2..c8b65361 100644 --- a/patacrep/authors.py +++ b/patacrep/authors.py @@ -5,8 +5,6 @@ import re LOGGER = logging.getLogger(__name__) -AUTHWORDS_KEYS = ["after", "ignore", "separators"] - RE_AFTER = r"^.*\b{}\b(.*)$" RE_SEPARATOR = r"^(.*)\b *{} *(\b.*)?$" @@ -15,23 +13,17 @@ def compile_authwords(authwords): This regexp will later be used to match these words in authors strings. """ - # Fill missing values - for key in AUTHWORDS_KEYS: - if key not in authwords: - authwords[key] = [] - - # Compilation - authwords['after'] = [ - re.compile(RE_AFTER.format(word), re.LOCALE) - for word in authwords['after'] - ] - authwords['separators'] = [ - re.compile(RE_SEPARATOR.format(word), re.LOCALE) - for word in ([" %s" % word for word in authwords['separators']] + [',', ';']) - ] - - return authwords - + return { + 'ignore': authwords.get('ignore', []), + 'after': [ + re.compile(RE_AFTER.format(word), re.LOCALE) + for word in authwords['after'] + ], + 'separators': [ + re.compile(RE_SEPARATOR.format(word), re.LOCALE) + for word in ([" %s" % word for word in authwords['separators']] + [',', ';']) + ], + } def split_author_names(string): r"""Split author between first and last name. diff --git a/patacrep/build.py b/patacrep/build.py index 73ba64f3..ed24664d 100644 --- a/patacrep/build.py +++ b/patacrep/build.py @@ -1,7 +1,6 @@ """Build a songbook, according to parameters found in a .sb file.""" import codecs -import copy import glob import logging import threading @@ -85,9 +84,7 @@ class Songbook(object): config['_template'] = renderer.get_all_variables(self.config.get('template', {})) - config['_compiled_authwords'] = authors.compile_authwords( - copy.deepcopy(config['authors']) - ) + config['_compiled_authwords'] = authors.compile_authwords(config['authors']) # Loading custom plugins config['_content_plugins'] = files.load_plugins(