From cf51440b64692065eb81408c03695c0645096796 Mon Sep 17 00:00:00 2001 From: Greg Wilson Date: Wed, 13 Jul 2016 07:19:05 -0400 Subject: [PATCH] Making the code a little more robust --- bin/extract_figures.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/extract_figures.py b/bin/extract_figures.py index 7eb55f0..15b079e 100755 --- a/bin/extract_figures.py +++ b/bin/extract_figures.py @@ -58,7 +58,8 @@ def find_image_nodes(doc, result): if (doc['type'] == 'img') or \ ((doc['type'] == 'html_element') and (doc['value'] == 'img')): - result.append({'alt': doc['attr']['alt'], 'src': doc['attr']['src']}) + alt = doc['attr'].get('alt', '') + result.append({'alt': alt, 'src': doc['attr']['src']}) else: for child in doc.get('children', []): find_image_nodes(child, result)