ps/str,...

This commit is contained in:
Marc Beninca 2024-09-13 23:54:32 +02:00
parent 521884102e
commit cd4e7403ae
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

View file

@ -5,7 +5,7 @@ import subprocess
from rwx import txt from rwx import txt
def get_tuples_args(*items: str | tuple[str]) -> list[str]: def get_tuples_args(*items: str | tuple[str, ...]) -> list[str]:
"""Turn arguments tuples into an arguments list.""" """Turn arguments tuples into an arguments list."""
args: list[str] = [] args: list[str] = []
for item in items: for item in items:
@ -16,21 +16,21 @@ def get_tuples_args(*items: str | tuple[str]) -> list[str]:
return args return args
def run(*items: str | tuple[str]) -> subprocess.CompletedProcess: def run(*items: str | tuple[str, ...]) -> subprocess.CompletedProcess:
"""Run from a list of arguments tuples.""" """Run from a list of arguments tuples."""
return subprocess.run( return subprocess.run(
get_tuples_args(*items), capture_output=False, check=True get_tuples_args(*items), capture_output=False, check=True
) )
def run_line(*items: str | tuple[str], charset: str = txt.CHARSET) -> str: def run_line(*items: str | tuple[str, ...], charset: str = txt.CHARSET) -> str:
"""Run and return output line.""" """Run and return output line."""
line, *_ = run_lines(*items, charset=charset) line, *_ = run_lines(*items, charset=charset)
return line return line
def run_lines( def run_lines(
*items: str | tuple[str], charset: str = txt.CHARSET *items: str | tuple[str, ...], charset: str = txt.CHARSET
) -> list[str]: ) -> list[str]:
"""Run and return output lines.""" """Run and return output lines."""
process = subprocess.run( process = subprocess.run(