diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-08-20 20:34:34 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-08-20 20:35:14 +0100 |
| commit | 1c14ed25d75caf3228a92d8f7292bf0bf040653b (patch) | |
| tree | aa36f672e71baebf7b870a8be609d1990dd450e3 /mammoth/docx/body_xml.py | |
| parent | 06ac97ac681accc691affdfafec97ded54faba23 (diff) | |
Fix: cannot read file objects with name attribute
Diffstat (limited to 'mammoth/docx/body_xml.py')
| -rw-r--r-- | mammoth/docx/body_xml.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/mammoth/docx/body_xml.py b/mammoth/docx/body_xml.py index 9588bfe..b605354 100644 --- a/mammoth/docx/body_xml.py +++ b/mammoth/docx/body_xml.py @@ -4,6 +4,7 @@ from .. import documents from .. import results from .. import lists from .xmlparser import node_types +from .files import InvalidFileReferenceError def reader(numbering=None, @@ -222,7 +223,11 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f return _combine_results(map(lambda blip: _read_blip(blip, alt_text), blips)) def _read_blip(element, alt_text): - image_path, open_image = _read_blip_image(element) + try: + image_path, open_image = _read_blip_image(element) + except InvalidFileReferenceError as error: + return _empty_result_with_messages([results.warning(str(error))]) + content_type = content_types.find_content_type(image_path) image = documents.image(alt_text=alt_text, content_type=content_type, open=open_image) @@ -261,6 +266,8 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f def open_image(): return files.open(image_path) + files.verify(image_path) + return image_path, open_image def note_reference_reader(note_type): |
