Skip to content

Commit

Permalink
Merge pull request #3 from vnitinv/junos-sax-parser
Browse files Browse the repository at this point in the history
parse10 already takes care of remaining data
  • Loading branch information
Nitin Kr authored Oct 21, 2019
2 parents 3003ba8 + 3855350 commit 8b7a114
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions ncclient/transport/third_party/junos/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,11 @@ def _delimiter_check(self, data):
msg, delim, remaining = data.partition(MSG_DELIM)
self._session._buffer.seek(0, os.SEEK_END)
self._session._buffer.write(delim.encode())
if remaining.strip() != '':
self._session._buffer.write(remaining.encode())
# we need to renew parser, as old parser is gone.
self.sax_parser = make_parser()
self.sax_parser.setContentHandler(SAXParser(self._session))
if remaining.strip() != '':
try:
self.sax_parser.feed(remaining)
except SAXFilterXMLNotFoundError:
self._parse10()
self.logger.debug('switching from sax to dom parsing')
self._session.parser = DefaultXMLParser(self._session)
self._session.parser.parse(remaining.encode())
elif RPC_REPLY_END_TAG in data:
logger.warning("Check for rpc reply end tag within data received: %s" % data)
msg, delim, remaining = data.partition(RPC_REPLY_END_TAG)
Expand Down

0 comments on commit 8b7a114

Please sign in to comment.