Browse documentation
DocsAPI module
lokit.stream & async
Use bounded iteration for large inputs and async applications.
01
Synchronous document streams
stream.lokit, stream.tmx, stream.tmx_parallel, stream.xliff, stream.docx, and stream.pptx return StreamingStructure. Document metadata is available before the one-shot .items iterable is consumed.
stream.py
import lokit
document = lokit.stream.xliff("messages.xliff")print(document.source_locale, document.target_locales)
for unit_id, unit in document.items: process(unit_id, unit)02
Async iteration and early exit
Async parsers and streams yield (unit_id, Data) and keep blocking parser work off the event-loop thread. Full consumption closes bounded bridges automatically. If you intentionally stop early on a closeable bridge such as .lokit, use it as an async context manager.
early_exit.py
async with lokit.stream.async_.lokit("messages.lokit") as units: async for unit_id, unit in units: print(unit_id, unit.source) break03
Rows, batches, and JSONL
stream.to_dict() lazily projects interchange rows. stream.async_.tmx_batches() yields bounded lists for batch consumers. stream.write_jsonl() writes line-delimited records; it is not a JSON document parser.