Checks if the current host has unsaved changes compared to its original loaded state.
(self)
| 1391 | pass |
| 1392 | |
| 1393 | def is_host_dirty(self) -> bool: |
| 1394 | """Checks if the current host has unsaved changes compared to its original loaded state.""" |
| 1395 | if not self.current_host or not self.original_host_state: |
| 1396 | return False |
| 1397 | |
| 1398 | if sorted(self.current_host.patterns) != sorted( |
| 1399 | self.original_host_state.patterns |
| 1400 | ): |
| 1401 | return True |
| 1402 | |
| 1403 | if len(self.current_host.options) != len(self.original_host_state.options): |
| 1404 | return True |
| 1405 | |
| 1406 | current_options_dict = { |
| 1407 | opt.key.lower(): opt.value for opt in self.current_host.options |
| 1408 | } |
| 1409 | original_options_dict = { |
| 1410 | opt.key.lower(): opt.value for opt in self.original_host_state.options |
| 1411 | } |
| 1412 | |
| 1413 | if current_options_dict != original_options_dict: |
| 1414 | return True |
| 1415 | |
| 1416 | current_raw_clean = [line.rstrip("\n") for line in self.current_host.raw_lines] |
| 1417 | original_raw_clean = [ |
| 1418 | line.rstrip("\n") for line in self.original_host_state.raw_lines |
| 1419 | ] |
| 1420 | |
| 1421 | return current_raw_clean != original_raw_clean |
| 1422 | |
| 1423 | def _collect_field_errors(self) -> dict: |
| 1424 | errors: dict[str, str] = {} |
no outgoing calls
no test coverage detected