eds: Support custom_options for unknown EDS fields#653
Open
bizfsc wants to merge 1 commit intocanopen-python:masterfrom
Open
eds: Support custom_options for unknown EDS fields#653bizfsc wants to merge 1 commit intocanopen-python:masterfrom
bizfsc wants to merge 1 commit intocanopen-python:masterfrom
Conversation
When importing an EDS/DCF file, any key that is not part of the CiA 306 standard field set is now collected into a custom_options dict on the object. This allows applications to round-trip vendor-specific metadata without losing it. Co-authored-by: FedericoSpada <FedericoSpada@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Supersedes #615.
When importing an EDS/DCF file, any key that is not part of the CiA 306 standard field set is now collected into a
custom_optionsdict on the object. This allows applications to round-trip vendor-specific metadata without losing it.Changes
ODVariable,ODRecordandODArraygain acustom_options: dictattribute (default{})._STANDARD_OPTIONSset ineds.pylists all keys that are parsed explicitly (includingObjFlagsandDenotationwhich are handled by a separate PR)._get_custom_options(eds, section)helper collects every key that is not in_STANDARD_OPTIONS.custom_optionsis populated for top-level VAR/DOMAIN, ARRAY and RECORD objects as well as for sub-variables viabuild_variable().export_variable()andexport_record()writecustom_optionsback to the EDS file, preserving all unknown fields through a round-trip.from canopen.objectdictionary import …, objectcodes).DOMAIN/VAR/ARR/RECORDconstants removed; replaced withobjectcodes.DOMAIN/VAR/ARRAY/RECORD.Tests
test_reading_custom_options— VAR withCategory=Motor,Offset=100test_custom_options_standard_keys_excluded— standard keys absent fromcustom_optionstest_custom_options_empty_for_standard_object— heartbeat time has{}test_custom_options_record— RECORD-levelcustom_optionstest_roundtrip_custom_options— full EDS export/import cycle preserves valuestest_roundtrip_custom_options_not_duplicated_as_standard— standard keys stay out after round-trip