Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions import.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@

# The encoding for input, output and internal representation. Leave alone.
ENCODING = 'UTF-8'
# The XML namespace we support.
XMLNS = 'http://www.mediawiki.org/xml/export-0.4/'

# The XML namespaces we support.
XMLNS = ['http://www.mediawiki.org/xml/export-0.4/', 'http://www.mediawiki.org/xml/export-0.6/']

def tzoffset():
r = time.strftime('%z')
Expand Down Expand Up @@ -109,7 +108,7 @@ def read(self, rev):

class StringStore:
def __init__(self, file):
self.struct = struct.Struct('=Bb255s')
self.struct = struct.Struct('=Bh255s')
self.maxid = -1
self.fh = open(file, 'wb+')
def write(self, id, text, flags = 1):
Expand Down Expand Up @@ -305,13 +304,13 @@ def parse(self, parser):
raise
def runHandler(self, name, attrs):
# Check the namespace.
if not name[0] == XMLNS:
if not name[0] in XMLNS:
if self.hpos > 0:
# If this is not the root element, simply ignore it.
return
else:
# If this is the root element, refuse to parse it.
raise XMLError('XML document needs to be in MediaWiki Export Format 0.4')
raise XMLError('XML document needs to be in MediaWiki Export Format 0.4 or 0.6')
# If there is no handler, this tag shall be ignored.
if self.handler == None:
return
Expand Down