From a4c6c2c7ba074b7db1ded2fa0f8a35419dc36296 Mon Sep 17 00:00:00 2001 From: Samuel Lai Date: Thu, 27 Feb 2014 18:13:04 +1100 Subject: [PATCH] Certain ignored post type IDs are now recognised by the error handler and messages printed as such. --- python/src/stackdump/commands/import_site.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/python/src/stackdump/commands/import_site.py b/python/src/stackdump/commands/import_site.py index f2b71db..3beebe9 100644 --- a/python/src/stackdump/commands/import_site.py +++ b/python/src/stackdump/commands/import_site.py @@ -260,8 +260,20 @@ class PostContentHandler(xml.sax.ContentHandler): d['answers'] = [ ] d['answerCount'] = int(attrs.get('AnswerCount', 0)) d['viewCount'] = int(attrs.get('ViewCount', 0)) + elif attrs['PostTypeId'] == '3': + raise ValueError('Skipping row ID [%s] as it is an orphaned tag wiki page (PostTypeId [3]).' % (attrs.get('Id', -1))) + elif attrs['PostTypeId'] == '4': + raise ValueError('Skipping row ID [%s] as it is a tag wiki excerpt (PostTypeId [4]).' % (attrs.get('Id', -1))) + elif attrs['PostTypeId'] == '5': + raise ValueError('Skipping row ID [%s] as it is a tag wiki page (PostTypeId [5]).' % (attrs.get('Id', -1))) + elif attrs['PostTypeId'] == '6': + raise ValueError('Skipping row ID [%s] as it is a moderator nomination post (PostTypeId [6]).' % (attrs.get('Id', -1))) + elif attrs['PostTypeId'] == '7': + raise ValueError('Skipping row ID [%s] as it is a wiki placeholder page (PostTypeId [7]).' % (attrs.get('Id', -1))) + elif attrs['PostTypeId'] == '8': + raise ValueError('Skipping row ID [%s] as it is an privilege wiki page (PostTypeId [8]).' % (attrs.get('Id', -1))) else: - raise ValueError('Unknown PostTypeId [%s] for row ID [%s]. Probably a tag wiki page.' % (attrs.get('PostTypeId', -1), attrs.get('Id', -1))) + raise ValueError('Unknown PostTypeId [%s] for row ID [%s].' % (attrs.get('PostTypeId', -1), attrs.get('Id', -1))) if 'AcceptedAnswerId' in attrs: d['acceptedAnswerId'] = int(attrs.get('AcceptedAnswerId', 0))