mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Project import generated by Copybara. GitOrigin-RevId: 715c8e8372d936f447f2937aab6b1a22dc619126
26 lines
722 B
Python
26 lines
722 B
Python
# notrack
|
|
from __future__ import annotations
|
|
|
|
from typing import Iterable, List, Tuple, Union
|
|
|
|
from .command import Command
|
|
|
|
|
|
def flatten_args_commands(
|
|
*commands: Union[Command, Iterable[Command]]
|
|
) -> Tuple[Command, ...]:
|
|
flattened_commands: List[Command] = []
|
|
for command in commands:
|
|
if isinstance(command, Command):
|
|
flattened_commands.append(command)
|
|
elif isinstance(command, Iterable):
|
|
flattened_commands.extend(flatten_args_commands(*command))
|
|
return tuple(flattened_commands)
|
|
|
|
|
|
def format_args_kwargs(*args, **kwargs) -> str:
|
|
return ", ".join(
|
|
[repr(arg) for arg in args]
|
|
+ [f"{key}={repr(value)}" for key, value in kwargs.items()]
|
|
)
|