Add missing addendum config check

This commit is contained in:
Tim Van Baak 2019-05-20 20:47:39 -07:00
parent 31f401400c
commit 699dce47af
2 changed files with 13 additions and 6 deletions

View File

@ -167,7 +167,7 @@ class LexiconArticle:
return articles return articles
@staticmethod @staticmethod
def interlink(lexicon_articles): def interlink(lexicon_articles, config):
""" """
Fills out fields on articles that require other articles for context. Fills out fields on articles that require other articles for context.
Creates phantom articles. Creates phantom articles.
@ -175,10 +175,17 @@ class LexiconArticle:
# Preliminary assertion that title/turn is unique # Preliminary assertion that title/turn is unique
keys = set() keys = set()
for article in lexicon_articles: for article in lexicon_articles:
if (article.title, article.turn) in keys: if config['ALLOW_ADDENDA'].lower() == "true":
raise ValueError("Found two articles with title '{}' and turn '{}'".format( key = (article.title, article.turn)
article.title, article.turn)) if key in keys:
keys.add((article.title, article.turn)) raise ValueError("Found two articles with title '{}' and turn '{}'".format(
*key))
else:
key = article.title
if key in keys:
raise ValueError("Found two articles with title '{}'".format(
article.title))
keys.add(key)
# Sort out which articles are addendums and which titles are phantoms # Sort out which articles are addendums and which titles are phantoms
written_titles = set() written_titles = set()
cited_titles = set() cited_titles = set()

View File

@ -416,7 +416,7 @@ def build_all(path_prefix, lexicon_name):
# Once they've been populated, the articles list has the titles of all articles # Once they've been populated, the articles list has the titles of all articles
# Sort this by turn before title so prev/next links run in turn order # Sort this by turn before title so prev/next links run in turn order
articles = sorted( articles = sorted(
LexiconArticle.interlink(articles), LexiconArticle.interlink(articles, config),
key=lambda a: (a.turn, utils.titlesort(a.title))) key=lambda a: (a.turn, utils.titlesort(a.title)))
def pathto(*els): def pathto(*els):