Add helpers filter_cmds and combine_cmds

main
Felix Stupp 2 years ago
parent 308eb70900
commit 79fca1994c
Signed by: zocker
GPG Key ID: 93E1BD26F6B02FB7

@ -32,6 +32,7 @@ import shlex
import sys import sys
from typing import ( from typing import (
Dict, Dict,
Iterable,
List, List,
Mapping, Mapping,
NewType, NewType,
@ -122,6 +123,14 @@ PODMAN_COMPOSE_EXEC = CommandArgs(
# === helpers # === helpers
def filter_cmds(command: Iterable[Optional[str]]) -> CommandArgs:
return CommandArgs([arg for arg in command if arg is not None])
def combine_cmds(*commands: CommandArgs | List[Optional[str]]) -> CommandArgs:
return CommandArgs([arg for cmd in commands for arg in filter_cmds(cmd)])
@wraps(print) @wraps(print)
def error(*args, **kwargs): def error(*args, **kwargs):
ret = print(*args, file=sys.stderr, **kwargs) ret = print(*args, file=sys.stderr, **kwargs)

Loading…
Cancel
Save