pythia.cli.app#

Command-line interfact typer application for pythia.

Its a typer application mimmicking gst-launch.

class pythia.cli.app.Exit(value)[source]#

Bases: Enum

Pythia cli exit wrapper.

EXTRACTION_NOT_BOUND = 4#
INVALID_EXTRACTION = 3#
INVALID_PIPELINE = 2#
UNPLAYABLE_PIPELINE = 5#
class pythia.cli.app.Mode(value)[source]#

Bases: str, Enum

Pipeline template loading from cli.

ARGV = 'ARGV'#

Pipeline template from argv.

FILE = 'FILE'#

Pipeline template from file.

_generate_next_value_(start, count, last_values)#

Generate the next value when not given.

name: the name of the member start: the initial start value or None count: the number of existing members last_value: the last value assigned or None

_member_map_ = {'ARGV': Mode.ARGV, 'FILE': Mode.FILE}#
_member_names_ = ['FILE', 'ARGV']#
_member_type_#

alias of str

_value2member_map_ = {'ARGV': Mode.ARGV, 'FILE': Mode.FILE}#
pythia.cli.app._ctx_cb() Tuple[List[str], Dict[str, Any]][source]#
pythia.cli.app._jinja_renderer(pipeline_template: str, context: dict) str[source]#
pythia.cli.app._native_renderer(pipeline_template: str, context: dict) str[source]#
pythia.cli.app._receive_any_return_kw(*_, **kw)[source]#
pythia.cli.app._validate_extractors(extractor: Optional[List[str]]) Dict[str, Dict[Literal['sink', 'src'], list]][source]#
pythia.cli.app._validate_pipeline(pipeline_string: str, *, check: bool = True) int[source]#
pythia.cli.app.build_pipeline(pipeline_parts: Optional[List[str]], pipeline_file: Optional[Path], ctx: Context, *, extra_ctx: Optional[Tuple[List[str], Dict[str, Any]]]) str[source]#

Construct a pipeline either from args or file.

Parameters:
  • pipeline_parts – console-split sections of a pipeline, eg as received from sys.argv.

  • pipeline_file – Location to read the template pipieline from.

  • ctx – typer context - used to print app help in case of problems.

  • extra_ctx – Additional context to render the pipeline template.

Returns:

The pipeline (either args or from file), parsed as a template, then injected with the additional context (if any).

pythia.cli.app.choose_renderer(pipeline_template: str) Callable[[str, Dict[str, Any]], str][source]#

Decide wether to use jinja or vanilla python template.

If the syntax is detected as jinja but its not installed, issue a warning and fall back to native python.

Parameters:

pipeline_template – Inspected to decide its underlying syntax.

Returns:

One of the available template renderers - _native_renderer()

or _jinja_renderer().

pythia.cli.app.define_template(ctx, pipeline_file: Optional[Path], pipeline_parts: Optional[List[str]]) Tuple[Mode, str][source]#

Construct a pipeline template wither from a file or its parts.

Parameters:
  • ctx – click application context - used to print help on incorrect usage.

  • pipeline_file – path to a nonempty file with a gst-launch-like pipeline as its contents.

  • pipeline_parts – console-split sections of a pipeline, eg as received from sys.argv.

Returns:

The pipeline template as a string.

Raises:

Abort – Either both or none of the exclusive (pipeline_file, pipeline_parts) was supplied.

Either pipeline_file or pipeline_parts must be passed.

pythia.cli.app.main(ctx: ~typer.models.Context, extra_ctx: ~typing.Optional[str] = <typer.models.OptionInfo object>, pipeline_parts: ~typing.Optional[~typing.List[str]] = <typer.models.ArgumentInfo object>, pipeline_file: ~typing.Optional[~pathlib.Path] = <typer.models.OptionInfo object>, extractor: ~typing.Optional[~typing.List[str]] = <typer.models.OptionInfo object>, _: ~typing.Optional[bool] = <typer.models.OptionInfo object>, dry_run: bool = <typer.models.OptionInfo object>, check: bool = <typer.models.OptionInfo object>) None[source]#
pythia.cli.app.parse_arbitrary_argv(component: Callable, args: List[str]) Tuple[List[str], Dict[str, Any]][source]#

Parse arguments into positional and named according to a function.

Parameters:
  • component – function to supply param spec and metadata.

  • args – list of positional arguments to parse.

Returns:

Positional arguments. Named value pairs dictionary extracted from the input arg list.

Examples

>>> def asdf()

See also

fire.core._Fire() and its call to fire.core._CallAndUpdateTrace()

pythia.cli.app.pipe_from_file(path: Path) str[source]#

Read a gst-launch-like pipeline from a file.

Parameters:

path – Location of the pipeline. If set to Path(“-“), reads from stdin instead.

Returns:

The pipeline string.

pythia.cli.app.pipe_from_parts(parts: Collection[str]) str[source]#

Join sys.argv-split strings wuith spaces.

Parameters:

parts – Strings to be joined.

Returns:

The strings, joined with simple spaces.

pythia.cli.app.version_callback(value: bool) None[source]#

Echo pythia version and exit.

Parameters:

value – If set, echos pythia version and exit.

Raises:

Exit – when value is passed, to exit the program.