Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for using dot (.) to get subobjects from the OD #426

Merged

Conversation

sveinse
Copy link
Collaborator

@sveinse sveinse commented May 9, 2024

This PR introduces the ability to use dot to access sub objects from the OD.

od: ObjectDictionary
v = od["Parameter"]["Subparam"].raw   # The current way
v = od["Parameter.Subparam"].raw      # The newly added way

The rationale is that when working with PDOs this syntax is used and it would make sense to have the same mechanism for SDO.

rpdo = remotenote.rpdo[1]
rpdo["Parameter.Subparam"].phys = 80

sdo = remotenode.sdo
sdo["Parameter.SubParam"].phys = 80

The current ways of accessing using multiple __getitem__ works fine. The only drawback is if an object has period (.) in its name.

Unittests have been updated as a part of this PR.

Copy link
Owner

@christiansandberg christiansandberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a good addition. Maybe it should also be added to the docs?

@sveinse
Copy link
Collaborator Author

sveinse commented May 13, 2024

@christiansandberg I added a few examples for the documentation

Add more compact and readable split

Co-authored-by: Erlend E. Aasland <[email protected]>
@sveinse
Copy link
Collaborator Author

sveinse commented May 16, 2024

As this is approved by @christiansandberg, can someone with write access, please commit this? @acolomb perhaps? Thanks!

@christiansandberg christiansandberg merged commit 54ebbd4 into christiansandberg:master May 16, 2024
1 check passed
@sveinse
Copy link
Collaborator Author

sveinse commented May 16, 2024

Thank you @christiansandberg

@sveinse sveinse deleted the feature-od-dot-support branch May 16, 2024 15:53
@acolomb acolomb added this to the v2.3.0 milestone Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants