Skip to main content

PyMCAP

This provides a Python interface to the Go MCAP CLI tool, so that you can merge MCAP files and recover corrupted ones conveniently from your Python code.

Installation

pip install pymcap

Quickstart

from pathlib import Path
from pymcap import PyMCAP

# Initialize PyMCAP
pymc = PyMCAP()

# Get MCAP CLI version
print(pymc.mcap_cli_version)

# Check if an MCAP file is corrupted
is_corrupted = pymc.is_mcap_corrupted(Path("my_file.mcap"))
print(f"Is file corrupted: {is_corrupted}")

# Recover a corrupted MCAP file
result = pymc.recover(
    file=Path("corrupted.mcap"),
    out=Path("recovered.mcap"),  # Optional, default: file + "_recovered"
    inplace=True,  # Replace original file if True
)
print(f"Recovery successful: {result.success}")
print(f"Recovered file path: {result.output_file}")

# Merge multiple MCAP files
merged_result = pymc.merge(
    merge_files=[Path("file1.mcap"), Path("file2.mcap")],
    out=Path("merged.mcap")
)
print(f"Merge successful: {merged_result.success}")
print(f"Merged file path: {merged_result.output_file}")

Features

  • Python interface to MCAP CLI tools with a simple, intuitive API
  • Automatically downloads and bundles the MCAP CLI with the Python package - no separate installation needed
  • Corrupted MCAP file detection
  • Recovery of corrupted MCAP files
  • Merging of multiple MCAP files
  • Cross-platform support (Linux, macOS, Windows)
  • Support for both ARM64 and AMD64 architectures

API Reference

PyMCAP Class

PyMCAP(log_level="INFO")

Initializes a new PyMCAP instance with specified logging level.

Properties

  • mcap_cli_version: Returns the version of the MCAP CLI being used
  • version: Returns the version of the PyMCAP package

Methods

is_mcap_corrupted
is_mcap_corrupted(file: Path) -> bool

Checks if an MCAP file is corrupted.

  • Parameters:
    • file: Path to the MCAP file to check
  • Returns: True if the file is corrupted, False otherwise
recover
recover(
    file: Path,
    out: Path | None = None,
    inplace: bool = True,
    flags: str = ""
) -> McapCLIOutput

Recovers a corrupted MCAP file.

  • Parameters:
    • file: Path to the corrupted MCAP file
    • out: Output path for the recovered file (optional)
    • inplace: If True, replaces the original file with the recovered one
    • flags: Additional flags to pass to the MCAP CLI
  • Returns: McapCLIOutput object containing the operation result
merge
merge(
    merge_files: list[Path],
    out: Path,
    flags: str = ""
) -> McapCLIOutput

Merges multiple MCAP files into a single file.

  • Parameters:
    • merge_files: List of paths to MCAP files to merge
    • out: Output path for the merged file
    • flags: Additional flags to pass to the MCAP CLI
  • Returns: McapCLIOutput object containing the operation result

McapCLIOutput Class

Represents the output of an MCAP CLI command.

Properties

  • stdout: Standard output from the command
  • stderr: Standard error from the command
  • output_file: Path to the output file (if applicable)
  • success: Boolean indicating whether the command succeeded

Requirements

  • Python 3.8+
  • Operating system: Linux, macOS, or Windows
  • Architecture: ARM64 or AMD64

Testing

pytest tests

Contributing

Add the ci tag to your branch to run the CI Tests

License

MIT License

Acknowledgements

Built on the official MCAP CLI tool: https://mcap.dev

PyMCAP

This provides a python interface to the go MCAP cli tool, so that you can merge mcaps and recover them conveniently from your python code

Installation

pip install pymcap

Quickstart

from pymcap import PyMCAP
pymc = PyMCAP()
print(pymc.mcap_cli_version)

Features

  • Python interface to MCAP CLI tools.
  • Bundles the MCAP cli with the python package, so you don't need to install the MCAP CLI separately.

Requirements

  • Python 3.8+
  • Operating system: Linux, macOS, or Windows, with arm64 or amd64 architectures.

Testing

pytest tests

Contributing

Add the ci tag to your branch to run the CI Tests

License

MIT License

Acknowledgements

Built on the official MCAP CLI tool: https://mcap.dev

Metadata

Release files for pymcap 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pymcap 0.2
File Size Uploaded Provenance Actions
pymcap-0.2.tar.gz 5.0 kB Without provenance Details for pymcap-0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pymcap 0.2
File Interpreter ABI Platform Actions
pymcap-0.2-py3-none-any.whl Python 3 none any Details for pymcap-0.2-py3-none-any.whl

Total release size: 10.7 kB

Release files / pymcap-0.2.tar.gz

Download URL pymcap-0.2.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
56b4444a43017a30b2e2423d9105f5488082f1c08304b3e9ce5c0191fcb7da38
BLAKE2b-256 checksum
How to use checksums
7ece239d67fcb6abeeb0351296b0728b2773832365c5b7b30fb0bf9fa613d384
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.8

Release files / pymcap-0.2-py3-none-any.whl

Download URL pymcap-0.2-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a00300d5f34bc9faf5e0e408f3810a46c3605c903412f1cff13ee49c730c6230
BLAKE2b-256 checksum
How to use checksums
ac976fce53da5757206d60048c0e0b8a3d9f5546301d676198c6dda489e8b716
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.8

Security for pymcap 0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page