Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed Wordpress import when importing WXR files above version 1.1. #187

Merged
merged 1 commit into from

2 participants

@geekman

When the WXR version is >1.1, the first loop iteration will try with a non-existent wpns and item.find('%spost_type' % wpns) is None, hence .text will raise an exception.

The WXR that I exported has all types of items, hence it's more flexible to assign the post type, then filter for post and page types later.

@geekman geekman Fixed Wordpress import when importing WXR files above version 1.1.
Also handle all-in-one WXR files by importing only pages and posts.
243aa07
@posativ posativ merged commit e2b81aa into from
@posativ
Owner

Looks good, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 6, 2013
  1. @geekman

    Fixed Wordpress import when importing WXR files above version 1.1.

    geekman authored
    Also handle all-in-one WXR files by importing only pages and posts.
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 3 deletions.
  1. +6 −3 acrylamid/tasks/imprt.py
View
9 acrylamid/tasks/imprt.py
@@ -252,8 +252,8 @@ def generate(item):
'tags': [tag.text for tag in item.findall('category')]
}
- if item.find('%spost_type' % wpns).text == 'page':
- entry['type'] = 'page'
+ # attachment, nav_menu_item, page, post
+ entry['type'] = item.find('%spost_type' % wpns).text
if item.find('%sstatus' % wpns).text != 'publish':
entry['draft'] = True
@@ -276,7 +276,10 @@ def generate(item):
for version in range(1, 10):
wpns = '{http://wordpress.org/export/1.%i/}' % version
- return defaults, list(map(generate, tree.findall('channel/item')))
+ if tree.find('channel/%swxr_version' % wpns) is None:
+ continue
+ entries = list(map(generate, tree.findall('channel/item')))
+ return defaults, [entry for entry in entries if entry['type'] in ('page', 'post')]
def fetch(url, auth=None):
Something went wrong with that request. Please try again.