1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

fix parsing

This commit is contained in:
checktheroads
2020-06-03 08:55:46 -07:00
parent 672710f101
commit 50dbc75212

View File

@@ -83,22 +83,28 @@ class Connect:
log.debug(f"Pre-parsed responses:\n{output}")
parsed = ()
response = None
if not self.device.structured_output:
for coro in parsers:
for response in output:
_output = await coro(commands=self.query, output=response)
parsed += (_output,)
response = "\n\n".join(parsed)
elif (
self.device.structured_output
and self.device.nos in nos_parsers.keys()
and self.query_type in nos_parsers[self.device.nos].keys()
):
func = nos_parsers[self.device.nos][self.query_type]
response = func(output)
log.debug(f"Post-parsed responses:\n{response}")
if response is None:
try:
if not self.device.structured_output:
for coro in parsers:
for response in output:
_output = await coro(commands=self.query, output=response)
parsed += (_output,)
response = "\n\n".join(parsed)
elif (
self.device.structured_output
and self.device.nos in nos_parsers.keys()
and self.query_type in nos_parsers[self.device.nos].keys()
):
func = nos_parsers[self.device.nos][self.query_type]
response = func(output)
except Exception as err:
log.critical(str(err))
raise ResponseEmpty(params.messages.parsing_error)
if response is None:
response = "\n\n".join(output)
log.debug(f"Post-parsed responses:\n{response}")
return response
async def scrape_proxied(self):