Move class definition to utils so can be used from multiple kittens easily

This commit is contained in:
Kovid Goyal 2020-09-15 10:34:37 +05:30
parent 0a027fad9a
commit be29c4a243
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 10 additions and 9 deletions

View File

@ -18,9 +18,8 @@ from kitty.cli import parse_args
from kitty.cli_stub import RemoteFileCLIOptions from kitty.cli_stub import RemoteFileCLIOptions
from kitty.constants import cache_dir from kitty.constants import cache_dir
from kitty.typing import BossType from kitty.typing import BossType
from kitty.utils import command_for_open, get_editor, open_cmd from kitty.utils import command_for_open, get_editor, open_cmd, SSHConnectionData
from ..ssh.main import SSHConnectionData
from ..tui.handler import result_handler from ..tui.handler import result_handler
from ..tui.operations import ( from ..tui.operations import (
faint, raw_mode, reset_terminal, set_cursor_visible, styled faint, raw_mode, reset_terminal, set_cursor_visible, styled

View File

@ -8,7 +8,9 @@ import shlex
import subprocess import subprocess
import sys import sys
from contextlib import suppress from contextlib import suppress
from typing import List, NamedTuple, NoReturn, Optional, Set, Tuple from typing import List, NoReturn, Optional, Set, Tuple
from kitty.utils import SSHConnectionData
SHELL_SCRIPT = '''\ SHELL_SCRIPT = '''\
#!/bin/sh #!/bin/sh
@ -61,12 +63,6 @@ def get_ssh_cli() -> Tuple[Set[str], Set[str]]:
return set('-' + x for x in boolean_ssh_args), set('-' + x for x in other_ssh_args) return set('-' + x for x in boolean_ssh_args), set('-' + x for x in other_ssh_args)
class SSHConnectionData(NamedTuple):
binary: str
hostname: str
port: Optional[int] = None
def get_connection_data(args: List[str]) -> Optional[SSHConnectionData]: def get_connection_data(args: List[str]) -> Optional[SSHConnectionData]:
boolean_ssh_args, other_ssh_args = get_ssh_cli() boolean_ssh_args, other_ssh_args = get_ssh_cli()
found_ssh = '' found_ssh = ''

View File

@ -575,3 +575,9 @@ def parse_uri_list(text: str) -> Generator[str, None, None]:
continue continue
if purl.path: if purl.path:
yield unquote(purl.path) yield unquote(purl.path)
class SSHConnectionData(NamedTuple):
binary: str
hostname: str
port: Optional[int] = None