Skip to content

Commit

Permalink
fix parsing bug causing query failures, closes #90
Browse files Browse the repository at this point in the history
  • Loading branch information
thatmattlove committed Oct 11, 2020
1 parent 5e61e09 commit 14ec5da
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 51 deletions.
4 changes: 2 additions & 2 deletions hyperglass/execution/drivers/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ async def parsed_response( # noqa: C901 ("too complex")
and self.device.nos in structured_nos
and self.query_type not in structured_query_types
):
for coro in parsers:
for func in parsers:
for response in output:
_output = await coro(commands=self.query, output=response)
_output = func(commands=self.query, output=response)
parsed += (_output,)
response = "\n\n".join(parsed)
elif (
Expand Down
12 changes: 2 additions & 10 deletions hyperglass/parsing/common.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
"""Command parsers applied to all unstructured output."""


def remove_command(commands, output):
"""Remove anything before the command if found in output.
Arguments:
command {str} -- Command run for query
output {str} -- Raw output
Returns:
{str} -- Parsed output
"""
def remove_command(commands: str, output: str) -> str:
"""Remove anything before the command if found in output."""
_output = output.strip().split("\n")

for command in commands:
Expand Down
77 changes: 38 additions & 39 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ scrapli = {extras = ["asyncssh"], version = "^2020.9.26"}
uvicorn = "^0.11"
uvloop = "^0.14.0"
xmltodict = "^0.12.0"
cryptography = "3.0.0"

[tool.poetry.dev-dependencies]
bandit = "^1.6.2"
Expand Down

0 comments on commit 14ec5da

Please sign in to comment.