MCPcopy Create free account
hub / github.com/BuddySirJava/SSH-Studio / _parse_and_validate_raw_text

Method _parse_and_validate_raw_text

src/ui/host_editor.py:861–884  ·  view source on GitHub ↗

Parses raw lines and updates current_host and UI fields if valid.

(self, current_lines: list[str])

Source from the content-addressed store, hash-verified

859 self._update_button_sensitivity()
860
861 def _parse_and_validate_raw_text(self, current_lines: list[str]):
862 """Parses raw lines and updates current_host and UI fields if valid."""
863 try:
864 temp_host = SSHHost.from_raw_lines(current_lines)
865 self.current_host.patterns = temp_host.patterns
866 self.current_host.options = temp_host.options
867 self.current_host.raw_lines = current_lines
868 self.emit("host-changed", self.current_host)
869 self._sync_fields_from_host()
870 self._update_button_sensitivity()
871 except ValueError as e:
872 error_msg = str(e)
873 if "No Host declaration found" in error_msg:
874 if any(
875 line.strip() and not line.strip().startswith("#")
876 for line in current_lines
877 ):
878 self.app._show_error(
879 "SSH host configuration must start with 'Host' declaration"
880 )
881 else:
882 self.app._show_error(f"Invalid raw host configuration: {e}")
883 except Exception as e:
884 self.app._show_error(f"Error parsing raw host config: {e}")
885
886 def _update_host_from_fields(self):
887 """Updates the current host object based on GUI field values.

Callers 1

_on_raw_text_changedMethod · 0.95

Calls 4

from_raw_linesMethod · 0.80
_show_errorMethod · 0.45

Tested by

no test coverage detected