From f9f8ac7ea17a77b28a5ec1ef8b4aadbf84e0364a Mon Sep 17 00:00:00 2001 From: Stuart Axon Date: Wed, 5 Dec 2018 21:43:44 +0000 Subject: [PATCH] Make tests work again. --- pelican/tools/pelican_import.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pelican/tools/pelican_import.py b/pelican/tools/pelican_import.py index b417f341..6f23ed97 100755 --- a/pelican/tools/pelican_import.py +++ b/pelican/tools/pelican_import.py @@ -720,9 +720,12 @@ def get_attachments(xml, resolve_by_id=False): attachedposts = defaultdict(set) for parent, url in attachments: - if parent in post_names: # check parent post is valid + try: parent_name = post_names[parent] - attachedposts[parent_name].add(url) + except KeyError: + # attachment's parent is not a valid post + parent_name = None + attachedposts[parent_name].add(url) attachment_links = defaultdict(set) if resolve_by_id and attachments_by_id: