diff --git a/netmiko/nokia/nokia_srl.py b/netmiko/nokia/nokia_srl.py index 781467aeb..4feafc6fd 100644 --- a/netmiko/nokia/nokia_srl.py +++ b/netmiko/nokia/nokia_srl.py @@ -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 = "#",