|
8 | 8 | # External Dependencies |
9 | 9 | import paramiko # type: ignore |
10 | 10 |
|
| 11 | +if typing.TYPE_CHECKING: |
| 12 | + # noinspection PyPackageRequirements |
| 13 | + import logwrap |
| 14 | + |
11 | 15 |
|
12 | 16 | # Parse default SSHConfig if available |
13 | 17 | SSH_CONFIG_FILE_SYSTEM = pathlib.Path("/etc/ssh/ssh_config") |
@@ -132,6 +136,34 @@ def __repr__(self) -> str: |
132 | 136 | f")" |
133 | 137 | ) |
134 | 138 |
|
| 139 | + def __pretty_repr__(self, log_wrap: "logwrap.PrettyRepr", indent: int = 0, no_indent_start: bool = False) -> str: |
| 140 | + """Make human readable representation of object. |
| 141 | +
|
| 142 | + :param log_wrap: logwrap instance |
| 143 | + :type log_wrap: logwrap.PrettyRepr |
| 144 | + :param indent: start indentation |
| 145 | + :type indent: int |
| 146 | + :param no_indent_start: do not indent open bracket and simple parameters |
| 147 | + :type no_indent_start: bool |
| 148 | + :return: formatted string |
| 149 | + :rtype: str |
| 150 | + """ |
| 151 | + next_indent = log_wrap.next_indent(indent) |
| 152 | + msg = ( |
| 153 | + f"{'':<{0 if no_indent_start else indent}}{self.__class__.__name__}(\n" |
| 154 | + f"{'':<{next_indent}}hostname={self.hostname!r},\n" |
| 155 | + f"{'':<{next_indent}}port={self.port!r},\n" |
| 156 | + f"{'':<{next_indent}}user={self.user!r},\n" |
| 157 | + f"{'':<{next_indent}}identityfile={self.identityfile!r},\n" |
| 158 | + f"{'':<{next_indent}}proxycommand={self.proxycommand!r},\n" |
| 159 | + f"{'':<{next_indent}}proxyjump={self.proxyjump!r},\n" |
| 160 | + f"{'':<{next_indent}}controlpath={self.controlpath!r},\n" |
| 161 | + f"{'':<{next_indent}}controlmaster={self.controlmaster!r},\n" |
| 162 | + f"{'':<{next_indent}}compression={self.compression!r},\n" |
| 163 | + f"{'':<{0 if no_indent_start else indent}})" |
| 164 | + ) |
| 165 | + return msg |
| 166 | + |
135 | 167 | @staticmethod |
136 | 168 | def _parse_optional_int(value: typing.Optional[typing.Union[str, int]]) -> typing.Optional[int]: |
137 | 169 | if value is None or isinstance(value, int): |
|
0 commit comments