Skip to content

Commit 6a5988b

Browse files
committed
Add method to iterate over passed XML
This is purely sugar, but it stops me from having to create a temp file or invoke io.StringIO myself. We already import io, so I don't think it adds any real overhead.
1 parent b443996 commit 6a5988b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

‎mw/xml_dump/iteration/iterator.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,13 @@ def from_file(cls, f):
186186
assert element.tag == "mediawiki"
187187
return cls.from_element(element)
188188

189+
@classmethod
190+
def from_ref(cls, ref):
191+
f = io.StringIO(ref)
192+
element = ElementIterator.from_file(f)
193+
assert element.tag == "mediawiki"
194+
return cls.from_element(element)
195+
189196
@classmethod
190197
def from_page_xml(cls, page_xml):
191198
header = """

0 commit comments

Comments
 (0)