MCPcopy Index your code
hub / github.com/BuddySirJava/SSH-Studio / validate

Method validate

src/ssh_config_parser.py:190–222  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

188 self._atomic_write(content)
189
190 def validate(self) -> List[str]:
191 errors: List[str] = []
192 seen: Dict[str, SSHHost] = {}
193 for host in self.config.hosts:
194 for pat in host.patterns:
195 if pat in seen:
196 errors.append(f"Duplicate host alias: {pat}")
197 else:
198 seen[pat] = host
199 for host in self.config.hosts:
200 port = host.get_option("Port")
201 if port:
202 try:
203 p = int(port)
204 if p < 1 or p > 65535:
205 errors.append(
206 f"Invalid port for host {host.patterns[0]}: {port}"
207 )
208 except ValueError:
209 errors.append(
210 f"Port is not an integer for host {host.patterns[0]}: {port}"
211 )
212 for host in self.config.hosts:
213 ident = host.get_option("IdentityFile")
214 if ident:
215 path = Path(ident).expanduser()
216 if not path.is_absolute():
217 path = Path.home() / ".ssh" / ident
218 if not path.exists():
219 errors.append(
220 f"IdentityFile not found for host {host.patterns[0]}: {ident}"
221 )
222 return errors
223
224 def _parse_main_lines(self, lines: List[str]) -> None:
225 self.config.hosts.clear()

Callers 2

_on_save_clickedMethod · 0.80
_on_save_clickedMethod · 0.80

Calls 1

get_optionMethod · 0.80

Tested by

no test coverage detected