Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Handle bibliography entries without keywords
  • Loading branch information
kthoden committed May 15, 2019
1 parent 7fef53a commit 6c738b8
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions eoatex2imxml.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8; mode: python -*-
# Time-stamp: <2019-05-14 17:09:18 (kthoden)>
# Time-stamp: <2019-05-15 16:51:31 (kthoden)>

"""
Converts Latex files into a customized DocBook XML file.
Expand Down Expand Up @@ -1185,9 +1185,23 @@ def bib_keywords_sanity_check(

# just for debugging (?):
logging.info("We want to collect the entries matching the keywords from the database.")
citations_with_keyword = [x["id"] for x in citations_json if keyword in x["keyword"]]
logging.debug(f"Found {libeoaconvert.plural(len(citations_with_keyword), 'citation')} with keyword {keyword} in database.")

citations_with_keyword = []
citations_without_keyword = []
# citations_with_keyword = [x["id"] for x in citations_json if keyword in x["keyword"]]
for cj in citations_json:
try:
if keyword in cj["keyword"]:
citations_with_keyword.append(cj["id"])
except KeyError:
logging.warning(f"Index entry {cj['id']} has no keyword. As long as it is not cited, this is no problem.")
citations_without_keyword.append(cj["id"])
pass
logging.debug(f"Found {libeoaconvert.plural(len(citations_with_keyword), 'citation')} with keyword {keyword} in database.")
cited_works_without_keyword = [x for x in citations_without_keyword if x in citekeys]
if cited_works_without_keyword:
logging.error(f"Found {libeoaconvert.plural(len(cited_works_without_keyword), 'work')} that are cited but have no keyword. Please assign one.")
sys.exit(1)
citations_to_format = [x for x in citations_with_keyword if x in citekeys]
logging.debug(f"Found {libeoaconvert.plural(len(citations_to_format), 'citation')} with keyword {keyword} that are actually cited.")

Expand Down

0 comments on commit 6c738b8

Please sign in to comment.