| Total Complexity | 3 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import json |
||
| 2 | import logging |
||
| 3 | from typing import Any, Protocol |
||
| 4 | |||
| 5 | from software_patterns import Proxy |
||
| 6 | |||
| 7 | __all__ = ['FFProbeProxy'] |
||
| 8 | |||
| 9 | |||
| 10 | logger = logging.getLogger(__name__) |
||
| 11 | |||
| 12 | |||
| 13 | class CLIResult(Protocol): |
||
| 14 | exit_code: int |
||
| 15 | stdout: str |
||
| 16 | stderr: str |
||
| 17 | |||
| 18 | |||
| 19 | class FFProbeSubjectType(Protocol): |
||
| 20 | def __init__(self, ffprobe_binary: str): |
||
| 21 | ... |
||
| 22 | |||
| 23 | def __call__(self, *ffprobe_cli_args, **subprocess_settings) -> CLIResult: |
||
| 24 | ... |
||
| 25 | |||
| 26 | |||
| 27 | class FFProbeProxy(Proxy[FFProbeSubjectType]): |
||
| 28 | """Proxy class for the ffprobe CLI.""" |
||
| 29 | |||
| 30 | def __call__(self, *ffprobe_cli_args: str, **subprocess_settings: Any) -> CLIResult: |
||
| 31 | logger.info( |
||
| 32 | "Running ffmpeg: %s", json.dumps(list(ffprobe_cli_args), indent=4, sort_keys=True) |
||
| 33 | ) |
||
| 34 | return self._proxy_subject(*ffprobe_cli_args, **subprocess_settings) |
||
| 35 |