From 391b85041d14b709db8b0587b175a1d65ad469e5 Mon Sep 17 00:00:00 2001 From: Castro0o Date: Sun, 9 Feb 2020 14:17:16 +0100 Subject: [PATCH] warnign about missing images --- functions.py | 2 +- query2html.py | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/functions.py b/functions.py index a92447f..2c9b054 100644 --- a/functions.py +++ b/functions.py @@ -53,7 +53,7 @@ def unpack_response(response): else: val = list(prop_val.values())[0] d[prop] = val - return d, fullurl + return page, d, fullurl def update_json(imgsjson_fn, img_dict, img_fn): diff --git a/query2html.py b/query2html.py index 2fe82e0..0a576ce 100644 --- a/query2html.py +++ b/query2html.py @@ -74,9 +74,14 @@ all_document_parts = '' # to append all content for answer in site.ask(query): publication_title = '' # print(answer, answer.keys()) - printout_dict, fullurl = unpack_response(answer) - # pprint(printout_dict) - img_info = images_info[printout_dict['page']] # find corresponding image in images.json + page, printout_dict, fullurl = unpack_response(answer) + print(page) + try: + img_info = images_info[printout_dict['page']] # find corresponding image in images.json + except KeyError: + print(Colors.WARNING, f"{printout_dict['page']} is not is missing from the local downloaded images") + print(Colors.GREEN, 'run python3 download_imgs.py to fix the issue', Colors.ENDC) + sys.exit() page = site.pages[[printout_dict['page']]] # request that page from wiki pagetext = page.text() pagetext_html = pandoc(pwd=wd, content=pagetext, format_in='mediawiki', format_out='html') @@ -98,9 +103,3 @@ for answer in site.ask(query): htmlfile.write(pub_html) all_document_parts = '' # Reset all_document_parts - -# TODO: include Creator Property value - -# TODO: address Dates: -# * date values coming from mw with timestamp, the missing valus are one -# This a MW issue!