mirror of
https://github.com/thatmattlove/hyperglass.git
synced 2026-01-17 08:48:05 +00:00
27 lines
782 B
Python
27 lines
782 B
Python
"""Remove anything before the command if found in output."""
|
|
|
|
# Standard Library
|
|
from typing import TYPE_CHECKING
|
|
|
|
# Local
|
|
from .._output import OutputPlugin
|
|
|
|
if TYPE_CHECKING:
|
|
# Project
|
|
from hyperglass.models.config.devices import Device
|
|
|
|
|
|
class RemoveCommand(OutputPlugin):
|
|
"""Remove anything before the command if found in output."""
|
|
|
|
def process(self, device_output: str, device: "Device") -> str:
|
|
"""Remove anything before the command if found in output."""
|
|
output = device_output.strip().split("\n")
|
|
|
|
for command in device.directive_commands:
|
|
for line in output:
|
|
if command in line:
|
|
idx = output.index(line) + 1
|
|
output = output[idx:]
|
|
|
|
return "\n".join(output)
|