Skip to content

Commit

Permalink
add similar to juniper prompt stripping
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffkala committed Nov 8, 2024
1 parent e34b895 commit 6d3493c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions netmiko/nokia/nokia_srl.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,32 @@ def session_preparation(self) -> None:
self.disable_paging(command=command, cmd_verify=True, pattern=r"#")
self.set_base_prompt()

def strip_prompt(self, *args: Any, **kwargs: Any) -> str:
"""Strip the line1 of multiline prompt from the output."""
a_string = super().strip_prompt(*args, **kwargs)
return self.strip_context_items(a_string)

def strip_context_items(self, a_string: str) -> str:
"""Strip NokiaSRL-specific output.
Nokia will put extra context is line 1 of the prompt, such as:
--{ running }--[ ]--
--{ candidate private private-admin }--[ ]--
--{ candidate private private-admin }--[ ]--
This method removes those lines.
"""
strings_to_strip = [
r"--{.*\B",
]

response_list = a_string.split(self.RESPONSE_RETURN)
last_line = response_list[-1]
for pattern in strings_to_strip:
if re.search(pattern, last_line, flags=re.I):
return self.RESPONSE_RETURN.join(response_list[:-1])
return a_string

def set_base_prompt(
self,
pri_prompt_terminator: str = "#",
Expand Down

0 comments on commit 6d3493c

Please sign in to comment.