Python xml.dom.pulldom.parse() Examples
The following are 30
code examples of xml.dom.pulldom.parse().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
xml.dom.pulldom
, or try the search function
.
Example #1
Source File: test_pulldom.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def parse(self, _): h = self._handler h.startDocument() # The next two items ensure that items preceding the first # start_element are properly stored and emitted: h.comment("a comment") h.processingInstruction("target", "data") h.startElement("html", AttributesImpl({})) h.comment("a comment") h.processingInstruction("target", "data") h.startElement("p", AttributesImpl({"class": "paraclass"})) h.characters("text") h.endElement("p") h.endElement("html") h.endDocument()
Example #2
Source File: test_pulldom.py From android_universal with MIT License | 6 votes |
def parse(self, _): h = self._handler h.startDocument() # The next two items ensure that items preceding the first # start_element are properly stored and emitted: h.comment("a comment") h.processingInstruction("target", "data") h.startElement("html", AttributesImpl({})) h.comment("a comment") h.processingInstruction("target", "data") h.startElement("p", AttributesImpl({"class": "paraclass"})) h.characters("text") h.endElement("p") h.endElement("html") h.endDocument()
Example #3
Source File: test_pulldom.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def parse(self, _): h = self._handler h.startDocument() # The next two items ensure that items preceding the first # start_element are properly stored and emitted: h.comment("a comment") h.processingInstruction("target", "data") h.startElement("html", AttributesImpl({})) h.comment("a comment") h.processingInstruction("target", "data") h.startElement("p", AttributesImpl({"class": "paraclass"})) h.characters("text") h.endElement("p") h.endElement("html") h.endDocument()
Example #4
Source File: test_pulldom.py From ironpython3 with Apache License 2.0 | 6 votes |
def parse(self, _): h = self._handler h.startDocument() # The next two items ensure that items preceding the first # start_element are properly stored and emitted: h.comment("a comment") h.processingInstruction("target", "data") h.startElement("html", AttributesImpl({})) h.comment("a comment") h.processingInstruction("target", "data") h.startElement("p", AttributesImpl({"class": "paraclass"})) h.characters("text") h.endElement("p") h.endElement("html") h.endDocument()
Example #5
Source File: minidom.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def parse(file, parser=None, bufsize=None): """Parse a file into a DOM by filename or file object.""" if parser is None and not bufsize: from xml.dom import expatbuilder return expatbuilder.parse(file) else: from xml.dom import pulldom return _do_pulldom_parse(pulldom.parse, (file,), {'parser': parser, 'bufsize': bufsize})
Example #6
Source File: test_pulldom.py From medicare-demo with Apache License 2.0 | 5 votes |
def testTextNodes(self): text = [] for event, node in pulldom.parse(self.testFile): if event == pulldom.CHARACTERS: text.append(node.data) try: result = u"".join(text) self.failUnlessEqual(repr(result), r"u'\n Some greek: \u0391\u0392\u0393\u0394\u0395\n \n \n \n'") except Exception, x: self.fail("Unexpected exception joining text pieces: %s" % str(x))
Example #7
Source File: test_pulldom.py From medicare-demo with Apache License 2.0 | 5 votes |
def testAttributes(self): attrText = [] for event, node in pulldom.parse(self.testFile): if event == pulldom.START_ELEMENT: for attrIx in range(node.attributes.length): attrText.append(node.attributes.item(attrIx).value) try: result = u"".join(attrText) self.failUnlessEqual(repr(result), r"u'\u0396\u0397\u0398\u0399\u039a'") except Exception, x: self.fail("Unexpected exception joining attribute text pieces: %s" % str(x))
Example #8
Source File: test_pulldom.py From medicare-demo with Apache License 2.0 | 5 votes |
def testProcessingInstruction(self): piText = [] for event, node in pulldom.parse(self.testFile): if event == pulldom.PROCESSING_INSTRUCTION: piText.append(node.data) try: result = u"".join(piText) # Weird how the repr for PI data is different from text and char data. # Still, the whole xml.dom.* and xml.sax.* hierarchy is rather a # labyrinthine mess under jython, mostly because it's so old, and # yet survived through major evolutionary changes in both jython and java. self.failUnlessEqual(repr(result), r"u'ΛΜΝΞΟ'") except Exception, x: self.fail("Unexpected exception joining pi data pieces: %s" % str(x))
Example #9
Source File: test_pulldom.py From medicare-demo with Apache License 2.0 | 5 votes |
def testComment(self): commentText = [] for event, node in pulldom.parse(self.testFile): if event == pulldom.COMMENT: commentText.append(node.data) try: result = u"".join(commentText) self.failUnlessEqual(repr(result), r"u'ΛΜΝΞΟ'") except Exception, x: self.fail("Unexpected exception joining comment data pieces: %s" % str(x))
Example #10
Source File: minidom.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def parse(file, parser=None, bufsize=None): """Parse a file into a DOM by filename or file object.""" if parser is None and not bufsize and sys.platform[:4] != "java": from xml.dom import expatbuilder return expatbuilder.parse(file) else: from xml.dom import pulldom return _do_pulldom_parse(pulldom.parse, (file,), {'parser': parser, 'bufsize': bufsize})
Example #11
Source File: test_pulldom.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def testTextNodes(self): text = [] for event, node in pulldom.parse(self.testFile): if event == pulldom.CHARACTERS: text.append(node.data) try: result = u"".join(text) self.failUnlessEqual(repr(result), r"u'\n Some greek: \u0391\u0392\u0393\u0394\u0395\n \n \n \n'") except Exception, x: self.fail("Unexpected exception joining text pieces: %s" % str(x))
Example #12
Source File: test_pulldom.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def testAttributes(self): attrText = [] for event, node in pulldom.parse(self.testFile): if event == pulldom.START_ELEMENT: for attrIx in range(node.attributes.length): attrText.append(node.attributes.item(attrIx).value) try: result = u"".join(attrText) self.failUnlessEqual(repr(result), r"u'\u0396\u0397\u0398\u0399\u039a'") except Exception, x: self.fail("Unexpected exception joining attribute text pieces: %s" % str(x))
Example #13
Source File: test_pulldom.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def testProcessingInstruction(self): piText = [] for event, node in pulldom.parse(self.testFile): if event == pulldom.PROCESSING_INSTRUCTION: piText.append(node.data) try: result = u"".join(piText) # Weird how the repr for PI data is different from text and char data. # Still, the whole xml.dom.* and xml.sax.* hierarchy is rather a # labyrinthine mess under jython, mostly because it's so old, and # yet survived through major evolutionary changes in both jython and java. self.failUnlessEqual(repr(result), r"u'ΛΜΝΞΟ'") except Exception, x: self.fail("Unexpected exception joining pi data pieces: %s" % str(x))
Example #14
Source File: test_pulldom.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def testComment(self): commentText = [] for event, node in pulldom.parse(self.testFile): if event == pulldom.COMMENT: commentText.append(node.data) try: result = u"".join(commentText) self.failUnlessEqual(repr(result), r"u'ΛΜΝΞΟ'") except Exception, x: self.fail("Unexpected exception joining comment data pieces: %s" % str(x))
Example #15
Source File: minidom.py From RevitBatchProcessor with GNU General Public License v3.0 | 5 votes |
def parse(file, parser=None, bufsize=None): """Parse a file into a DOM by filename or file object.""" if parser is None and not bufsize: from xml.dom import expatbuilder return expatbuilder.parse(file) else: from xml.dom import pulldom return _do_pulldom_parse(pulldom.parse, (file,), {'parser': parser, 'bufsize': bufsize})
Example #16
Source File: cimxml_parse.py From pywbem with GNU Lesser General Public License v2.1 | 5 votes |
def make_parser(stream_or_string): """Create a xml.dom.pulldom parser.""" if isinstance(stream_or_string, six.string_types): # XXX: the pulldom.parseString() function doesn't seem to # like operating on unicode strings! return pulldom.parseString(str(stream_or_string)) else: return pulldom.parse(stream_or_string)
Example #17
Source File: test_pulldom.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def parse(self, _): h = self._handler h.startDocument() h.startElement("html", AttributesImpl({})) h.comment("a comment") h.processingInstruction("target", "data") h.startElement("p", AttributesImpl({"class": "paraclass"})) h.characters("text") h.endElement("p") h.endElement("html") h.endDocument()
Example #18
Source File: minidom.py From unity-python with MIT License | 5 votes |
def parse(file, parser=None, bufsize=None): """Parse a file into a DOM by filename or file object.""" if parser is None and not bufsize: from xml.dom import expatbuilder return expatbuilder.parse(file) else: from xml.dom import pulldom return _do_pulldom_parse(pulldom.parse, (file,), {'parser': parser, 'bufsize': bufsize})
Example #19
Source File: minidom.py From android_universal with MIT License | 5 votes |
def parse(file, parser=None, bufsize=None): """Parse a file into a DOM by filename or file object.""" if parser is None and not bufsize: from xml.dom import expatbuilder return expatbuilder.parse(file) else: from xml.dom import pulldom return _do_pulldom_parse(pulldom.parse, (file,), {'parser': parser, 'bufsize': bufsize})
Example #20
Source File: test_pulldom.py From android_universal with MIT License | 5 votes |
def test_parse(self): """Minimal test of DOMEventStream.parse()""" # This just tests that parsing from a stream works. Actual parser # semantics are tested using parseString with a more focused XML # fragment. # Test with a filename: handler = pulldom.parse(tstfile) self.addCleanup(handler.stream.close) list(handler) # Test with a file object: with open(tstfile, "rb") as fin: list(pulldom.parse(fin))
Example #21
Source File: test_pulldom.py From android_universal with MIT License | 5 votes |
def test_thorough_parse(self): """Test some of the hard-to-reach parts of PullDOM.""" self._test_thorough(pulldom.parse(None, parser=SAXExerciser()))
Example #22
Source File: test_pulldom.py From android_universal with MIT License | 5 votes |
def parse(self, _): h = self._handler h.startDocument() h.startElement("html", AttributesImpl({})) h.comment("a comment") h.processingInstruction("target", "data") h.startElement("p", AttributesImpl({"class": "paraclass"})) h.characters("text") h.endElement("p") h.endElement("html") h.endDocument()
Example #23
Source File: minidom.py From canape with GNU General Public License v3.0 | 5 votes |
def parse(file, parser=None, bufsize=None): """Parse a file into a DOM by filename or file object.""" if parser is None and not bufsize: from xml.dom import expatbuilder return expatbuilder.parse(file) else: from xml.dom import pulldom return _do_pulldom_parse(pulldom.parse, (file,), {'parser': parser, 'bufsize': bufsize})
Example #24
Source File: minidom.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def parse(file, parser=None, bufsize=None): """Parse a file into a DOM by filename or file object.""" if parser is None and not bufsize and sys.platform[:4] != "java": from xml.dom import expatbuilder return expatbuilder.parse(file) else: from xml.dom import pulldom return _do_pulldom_parse(pulldom.parse, (file,), {'parser': parser, 'bufsize': bufsize})
Example #25
Source File: test_pulldom.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def testTextNodes(self): text = [] for event, node in pulldom.parse(self.testFile): if event == pulldom.CHARACTERS: text.append(node.data) try: result = u"".join(text) self.failUnlessEqual(repr(result), r"u'\n Some greek: \u0391\u0392\u0393\u0394\u0395\n \n \n \n'") except Exception, x: self.fail("Unexpected exception joining text pieces: %s" % str(x))
Example #26
Source File: test_pulldom.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def testAttributes(self): attrText = [] for event, node in pulldom.parse(self.testFile): if event == pulldom.START_ELEMENT: for attrIx in range(node.attributes.length): attrText.append(node.attributes.item(attrIx).value) try: result = u"".join(attrText) self.failUnlessEqual(repr(result), r"u'\u0396\u0397\u0398\u0399\u039a'") except Exception, x: self.fail("Unexpected exception joining attribute text pieces: %s" % str(x))
Example #27
Source File: test_pulldom.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def testProcessingInstruction(self): piText = [] for event, node in pulldom.parse(self.testFile): if event == pulldom.PROCESSING_INSTRUCTION: piText.append(node.data) try: result = u"".join(piText) # Weird how the repr for PI data is different from text and char data. # Still, the whole xml.dom.* and xml.sax.* hierarchy is rather a # labyrinthine mess under jython, mostly because it's so old, and # yet survived through major evolutionary changes in both jython and java. self.failUnlessEqual(repr(result), r"u'ΛΜΝΞΟ'") except Exception, x: self.fail("Unexpected exception joining pi data pieces: %s" % str(x))
Example #28
Source File: test_pulldom.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def testComment(self): commentText = [] for event, node in pulldom.parse(self.testFile): if event == pulldom.COMMENT: commentText.append(node.data) try: result = u"".join(commentText) self.failUnlessEqual(repr(result), r"u'ΛΜΝΞΟ'") except Exception, x: self.fail("Unexpected exception joining comment data pieces: %s" % str(x))
Example #29
Source File: minidom.py From Imogen with MIT License | 5 votes |
def parse(file, parser=None, bufsize=None): """Parse a file into a DOM by filename or file object.""" if parser is None and not bufsize: from xml.dom import expatbuilder return expatbuilder.parse(file) else: from xml.dom import pulldom return _do_pulldom_parse(pulldom.parse, (file,), {'parser': parser, 'bufsize': bufsize})
Example #30
Source File: xml_serializer.py From GTDWeb with GNU General Public License v2.0 | 5 votes |
def __init__(self, stream_or_string, **options): super(Deserializer, self).__init__(stream_or_string, **options) self.event_stream = pulldom.parse(self.stream, self._make_parser()) self.db = options.pop('using', DEFAULT_DB_ALIAS) self.ignore = options.pop('ignorenonexistent', False)