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

Make fields accessible by __getitem__ #23

Closed
Allan-S-Menefee opened this issue Apr 29, 2021 · 2 comments
Closed

Make fields accessible by __getitem__ #23

Allan-S-Menefee opened this issue Apr 29, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@Allan-S-Menefee
Copy link

I'm working with pyais and I'm finding the syntax NMEAMessage(blah).asdict()['mmsi']) clumsy. It should be possible to subscript these fields if NMEAMessage defined a getitem.

I will try to enter a pull request at some point, if I'm able to make time.

@M0r13n
Copy link
Owner

M0r13n commented Apr 29, 2021

Hey,

jep, you are definitely right. I believe that I tried it during the early days of Pyais. Back then I came across some kind of issue/error and stopped working on it. Anyway I would love to see a PR from you. Otherwise I will try to implement it, as soon as time allows!

Kind regards,
Leon

@M0r13n M0r13n added the enhancement New feature or request label May 1, 2021
@M0r13n
Copy link
Owner

M0r13n commented May 2, 2021

Hey,

I made the NMEAMessage class subscriptable. You can now access it's fields via []. See: https://pyais.readthedocs.io/en/latest/messages.html

Please note, that you provided NMEAMessage(blah).asdict()['mmsi']) as an example. This still won't work, because the NMEAMessage just capsules the NMEA message. It does not know or care about the actual payload. In order to access the mmsi, you first have to call NMEAMessage.decode().

@M0r13n M0r13n closed this as completed May 2, 2021
jimbofreedman pushed a commit to Spot-Ship/pyais that referenced this issue Oct 15, 2024
Batching the records to put into kinesis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants