def _parse_fileobj(self, outputfile):
     for action, elem in ET.iterparse(outputfile, events=('start', 'end')):
         if action == 'start':
             self.startElement(elem.tag, elem.attrib)
         elif action == 'end':
             self.endElement(elem.text or '')
             elem.clear()
     return DataModel(self._root_handler.data, self._context.split_results)
예제 #2
0
 def _test_string(self, xml):
     source = ETSource(xml)
     with source as src:
         assert_equals(src.read().decode('UTF-8'), xml)
     self._verify_string_representation(source, '<in-memory file>')
     assert_true(source._opened.closed)
     with ETSource(xml) as src:
         assert_equals(ET.parse(src).getroot().tag, 'tag')
예제 #3
0
 def _test_string(self, xml, encoding='UTF-8'):
     source = ETSource(xml)
     with source as src:
         content = src.read()
         expected = xml if isinstance(xml, bytes) else xml.encode(encoding)
         assert_equal(content, expected)
     self._verify_string_representation(source, '<in-memory file>')
     assert_true(source._opened.closed)
     with ETSource(xml) as src:
         assert_equal(ET.parse(src).getroot().tag, 'tag')
 def _test_string(self, xml):
     source = ETSource(xml)
     with source as src:
         content = src.read()
         if not IRONPYTHON:
             content = content.decode('UTF-8')
         assert_equal(content, xml)
     self._verify_string_representation(source, '<in-memory file>')
     assert_true(source._opened.closed)
     with ETSource(xml) as src:
         assert_equal(ET.parse(src).getroot().tag, 'tag')
예제 #5
0
 def _test_string(self, xml):
     source = ETSource(xml)
     with source as src:
         content = src.read()
         if not IRONPYTHON_WITH_BROKEN_ETREE:
             content = content.decode('UTF-8')
         assert_equal(content, xml)
     self._verify_string_representation(source, '<in-memory file>')
     assert_true(source._opened.closed)
     with ETSource(xml) as src:
         assert_equal(ET.parse(src).getroot().tag, 'tag')