MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / Parser

Class Parser

suds/sax/parser.py:104–137  ·  view source on GitHub ↗

SAX Parser

Source from the content-addressed store, hash-verified

102
103
104class Parser:
105 """ SAX Parser """
106
107 @classmethod
108 def saxparser(cls):
109 p = make_parser()
110 p.setFeature(feature_external_ges, 0)
111 h = Handler()
112 p.setContentHandler(h)
113 return (p, h)
114
115 def parse(self, file=None, string=None):
116 """
117 SAX parse XML text.
118 @param file: Parse a python I{file-like} object.
119 @type file: I{file-like} object.
120 @param string: Parse string XML.
121 @type string: str
122 """
123 timer = metrics.Timer()
124 timer.start()
125 sax, handler = self.saxparser()
126 if file is not None:
127 sax.parse(file)
128 timer.stop()
129 metrics.log.debug('sax (%s) duration: %s', file, timer)
130 return handler.nodes[0]
131 if string is not None:
132 if isinstance(string, str):
133 string = string.encode()
134 parseString(string, handler)
135 timer.stop()
136 metrics.log.debug('%s\nsax duration: %s', string, timer)
137 return handler.nodes[0]

Callers 5

downloadMethod · 0.90
invokeMethod · 0.90
getMethod · 0.90
get_replyMethod · 0.90
get_faultMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected