Save class objects in json and toml#145
Merged
Merged
Conversation
Collaborator
Author
|
I've made some modifications to allow the There is an interesting behavior with other tests that are now failing, but they are not directly related to the modifications of this PR. |
raphaeltimbo
added a commit
that referenced
this pull request
Jul 18, 2026
…om_dict Replace the per-class toml/json save/load logic with a single serializers module (ccp/data_io/serializers.py): - File format is decided by the file suffix (.toml or .json); the file_type parameter is removed. Unsupported suffixes raise ValueError instead of silently truncating or leaving variables unbound. - Writes are atomic (temp file + os.replace), so a failed dump never corrupts an existing file. - Point, Curve, Impeller, StraightThrough and BackToBack now expose public to_dict()/from_dict() (replacing _dict_to_save/_dict_from_load) and inherit save()/load() from a Serializable mixin. - Saved files record the writing library version in a "ccp_version" key, enabling future format migrations; Curve/Impeller files nest points under a "points" table. Legacy flat files still load. - Fix app pages passing io.StringIO to Impeller/StraightThrough/ BackToBack.load (broken since #145 for Impeller): pages now use the public from_dict with toml parsed in memory. - Tests: round-trips parametrized over toml and json for Point, Curve and Impeller, unsupported-format error case, and a legacy flat-file load test. Part of the app-page diff is whitespace-only: ruff format applied to files that were not formatted on main.
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.
Now, the user can save
ccpclass objects (Point,CurveandImpeller) intojsonortomlfile.