lacing.cli#
Command-line interface for lacing.
Built with cw (argparse + signature-driven argument inference).
The entry point is lacing — see project.scripts in pyproject.toml.
Subcommands:
- lacing convert <src> <dst> [–src-format] [–dst-format] [–rate]
Convert between any two registered formats. Inferred from extension; override with
--src-format/--dst-format.- lacing query <path> [–tier] [–start] [–end] [–relation]
Print annotations matching a tier and/or interval query. Output is JSON-lines on stdout.
- lacing validate <path> [–rate]
Load + re-dump round-trip; print a summary. Useful for sanity checking files before adopting them.
- lacing migrate <path> [–to-version N]
Upgrade a
.annotfile to the current store schema, in place, via the registered store-migration ladder. Explicit by design: opening a stale file never rewrites it.- lacing list-formats
Print every registered format adapter.
The CLI imports each Phase 0/1 adapter at startup so they self-register.
Add new adapters by editing _ENABLED_ADAPTERS in this module.
Type annotations are load-bearing here#
This module has from __future__ import annotations, so every annotation
below is a string at runtime. argh, which this CLI used to be built with,
reads __annotations__ raw and is therefore blind to PEP 563: under it,
--start, --end and --to-version all arrived as str no matter what
their annotations said, and the only defence was hand-written coercion in the
command body (which migrate had and query did not — so
lacing query f.vtt --start abc --end 2.0 used to get all the way into
RationalTime before failing).
_CONVENTION turns that off. resolve_hints=True makes cw resolve
annotations with typing.get_type_hints() instead of reading them raw, so
start: float | None becomes type=float at argparse’s type= site —
where a bad value is a clean usage: + exit 2 rather than a traceback from
somewhere in the call stack. Which means: **annotate the parameters, and do not
coerce in the body.**
Functions
|
Convert between annotation file formats. |
Print every registered format adapter. |
|
|
Entry point for the |
|
Upgrade PATH (a |
Build the |
|
|
Print annotations from PATH matching a tier and/or time-interval query. |
|
Round-trip PATH through load + dump and report a summary. |
- lacing.cli.convert(src, dst, *, src_format=None, dst_format=None, rate=24000)[source]#
Convert between annotation file formats.
SRC is a path to a recognized file (or
-for stdin bytes — not yet). DST is the output path. Formats are inferred from extensions; override with –src-format / –dst-format.- Return type:
- lacing.cli.main(argv=None)[source]#
Entry point for the
lacingconsole script.cw.runreturns the exit code where argh’sdispatchexited by itself, so theSystemExithere is what makeslacing no-such-commandexit 2 rather than 0.- Return type:
- lacing.cli.migrate(path, *, to_version=None)[source]#
Upgrade PATH (a
.annotfile) to the current store schema, in place.Migration is explicit — opening a stale file never rewrites it — so this verb is the ladder’s front door. Already-current files are a no-op.
--to-versionupgrades part-way (mainly useful in tests).- Return type:
- lacing.cli.mk_parser()[source]#
Build the
lacingparser — a plainargparse.ArgumentParser.- Return type:
- lacing.cli.query(path, *, tier=None, start=None, end=None, relation='intersects', src_format=None, rate=24000, limit=100)[source]#
Print annotations from PATH matching a tier and/or time-interval query.
Output is JSON-lines on stdout.
--startand--endare seconds.--relationis one of: intersects, during, contains, overlaps, meets, starts, finishes, equals.- Return type: