Skip to main content

MCAP libraries for Python

Project description

MCAP Python Library

This library provides classes for reading and writing the MCAP file format.

Reader Example

from mcap.mcap0.stream_reader import StreamReader

stream = open("example.mcap", "rb")
reader = StreamReader(stream)
for record in reader.records:
    print(record)

Writer Example

from time import time_ns
import json
from mcap.mcap0.writer import Writer

stream = open("example.mcap", "wb")
writer = Writer(stream)

# The library argument help identify what tool wrote the file.
writer.start(profile="x-custom", library="my-writer-v1")

schema_id = writer.register_schema(
    name="sample",
    encoding="jsonschema",
    data=json.dumps({
        "type": "object",
        "properties": {
            "sample": {
                "type": "string",
            }
        }
    }).encode()
)

channel_id = writer.register_channel(
    schema_id=schema_id,
    topic="sample_topic",
    message_encoding="json",
)

writer.add_message(
    channel_id=channel_id,
    log_time=time_ns(),
    data=json.dumps({"sample": "test"}).encode('utf-8'),
    publish_time=time_ns(),
)

writer.finish()
stream.close()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcap-0.0.4.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcap-0.0.4-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file mcap-0.0.4.tar.gz.

File metadata

  • Download URL: mcap-0.0.4.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for mcap-0.0.4.tar.gz
Algorithm Hash digest
SHA256 f80ee31c0e41e96e50ab0c53eb50b4d2235c2dd2e2d3d8206ab691262345b9fc
MD5 f017d442d68fc4a028aa26ad54529a2c
BLAKE2b-256 3744ad91ebe174afea0d65da196aa9af2d7751d27f679f2e89800bc03f0c4575

See more details on using hashes here.

File details

Details for the file mcap-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: mcap-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for mcap-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7e5e6a2bda628fe55b59ba87e583dae7040baf31ac53cef30a204ad85f17fb30
MD5 871febfc8264d72fcab4724d01a78d4f
BLAKE2b-256 6894874397b798b4821fe566cf84b63e1a5b5133880c2e89466881945bc40bab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page