mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-23 08:47:47 +02:00
Start work on config infrastructure for ssh kitten
This commit is contained in:
30
kittens/ssh/options/utils.py
Normal file
30
kittens/ssh/options/utils.py
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python
|
||||
# License: GPLv3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
|
||||
def init_results_dict(ans: Dict[str, Any]) -> Dict[str, Any]:
|
||||
ans['current_hostname'] = '*'
|
||||
ans['current_host_dict'] = chd = {'hostname': '*'}
|
||||
ans['per_host_dicts'] = {'*': chd}
|
||||
return ans
|
||||
|
||||
|
||||
ignored_dict_keys = tuple(init_results_dict({}))
|
||||
|
||||
|
||||
def hostname(val: str, dict_with_parse_results: Optional[Dict[str, Any]] = None) -> str:
|
||||
if dict_with_parse_results is not None:
|
||||
ch = dict_with_parse_results['current_hostname']
|
||||
if val != ch:
|
||||
hd = dict_with_parse_results.copy()
|
||||
for k in ignored_dict_keys:
|
||||
del hd[k]
|
||||
phd = dict_with_parse_results['per_host_dicts']
|
||||
phd[ch] = hd
|
||||
dict_with_parse_results.clear()
|
||||
dict_with_parse_results['per_host_dicts'] = phd
|
||||
dict_with_parse_results['current_hostname'] = val
|
||||
dict_with_parse_results['current_host_dict'] = phd.setdefault(val, {'hostname': val})
|
||||
return val
|
||||
Reference in New Issue
Block a user