From 4fbaa0bc22ed672bc8fb82345dc6223d414618e9 Mon Sep 17 00:00:00 2001 From: Klaus Thoden Date: Thu, 30 Aug 2018 17:51:29 +0200 Subject: [PATCH] Exception handling --- eoatex2imxml.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/eoatex2imxml.py b/eoatex2imxml.py index 57940b6..100a92e 100755 --- a/eoatex2imxml.py +++ b/eoatex2imxml.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8; mode: python -*- -# Time-stamp: <2018-08-24 17:17:19 (kthoden)> +# Time-stamp: <2018-08-30 17:51:23 (kthoden)> """ Converts Latex files into a customized DocBook XML file. @@ -1417,7 +1417,11 @@ def cleanup(): strTitle = current_citation["title"] # [1:-1] to remove parentheses around citations - citeauthoryear_value = form_cit.select("#citeauthoryear ~ p > span[data-cites='%s']" % string_citekey)[0].text[1:-1] + try: + citeauthoryear_value = form_cit.select("#citeauthoryear ~ p > span[data-cites='%s']" % string_citekey)[0].text[1:-1] + except IndexError: + print("Could not find {}. Exiting.".format(string_citekey)) + sys.exit() data_title_value = citeauthoryear_value if xmlCitation.tag == "EOAciteauthoryear": strCitation = citeauthoryear_value