A python package to interact with the MCAP CLI Tool
Project description
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 usedversion: 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 fileout: Output path for the recovered file (optional)inplace: If True, replaces the original file with the recovered oneflags: 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 mergeout: Output path for the merged fileflags: 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 commandstderr: Standard error from the commandoutput_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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pymcap-0.1.tar.gz.
File metadata
- Download URL: pymcap-0.1.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b82abc2fb203b75bb4794f5561f8a66a7a41ba12337c9ba83271eb286b3f3642
|
|
| MD5 |
641a7a3cdfab8193a670f3698b2fd6cb
|
|
| BLAKE2b-256 |
45a39ea341ba46a32fb435e3ca2d5736e09b663bb477dc9d6179efdfe8ea2654
|
File details
Details for the file pymcap-0.1-py3-none-any.whl.
File metadata
- Download URL: pymcap-0.1-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a893f8657240ab8ae5e149f80b041b45597a35657db2de857661f62bd050985
|
|
| MD5 |
98369cffe593cbac3b7b01277b6d3cf5
|
|
| BLAKE2b-256 |
f5e55f6a51972f626f23ebed51dfb79d95d18a110f28eaf8fbd7ad3c62058359
|