feat: Add SOR file writing to Python library#2
Merged
JamesHarrison merged 1 commit intomainfrom Aug 10, 2025
Merged
Conversation
This commit extends the Python library to allow writing SOR files. The following methods have been added to the `SORFile` class: - `to_bytes() -> bytes`: Returns the SOR file as a Python bytes object. - `write_file(path: str) -> None`: Writes the SOR file to the specified path. The core serialization logic already existed in the Rust library, and this change exposes it to the Python bindings using `pyo3`. A new test file has been added to verify the round-trip integrity of parsing a file, writing it back to bytes/file, and parsing it again. The tests confirm that all data blocks (except for the re-calculated MapBlock) are preserved correctly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change adds the ability to write OTDR SOR files from the Python library. It introduces two new methods on the
SORFileobject:to_bytes(): Serializes theSORFileobject into a Pythonbytesobject.write_file(path): Writes the serializedSORFileto a file on disk.This functionality is crucial for users who want to programmatically modify SOR files and save their changes.
The implementation exposes the existing Rust-based serialization functionality to the Python bindings. A comprehensive round-trip test suite has been added to ensure that files can be read, written, and read back without data loss.