Format host %x abbreviations.
(s: str, host: str | None = None, name: str | None = None, **extra: dict)
| 97 | |
| 98 | |
| 99 | def host_format(s: str, host: str | None = None, name: str | None = None, **extra: dict) -> str: |
| 100 | """Format host %x abbreviations.""" |
| 101 | host = host or gethostname() |
| 102 | hname, _, domain = host.partition('.') |
| 103 | name = name or hname |
| 104 | keys = dict( |
| 105 | { |
| 106 | 'h': host, |
| 107 | 'n': name, |
| 108 | 'd': domain, |
| 109 | 'i': _fmt_process_index, |
| 110 | 'I': _fmt_process_index_with_prefix, |
| 111 | }, |
| 112 | **extra, |
| 113 | ) |
| 114 | return simple_format(s, keys) |
no test coverage detected