Closed tloubrieu-jpl closed 7 months ago
Can you try this? This is the Pythonic way to do it, I believe.
pos = file.tell()
results = pkt.load(fh)
file.seek(pos)
I haven't seen any other APIs support the type of option you're proposing.. and it should be pretty easy without it so I'm hesitant to add a new keyword argument right now.
Ok, I understand your point. In my code I am parsing 3 times the same stream which made it easier to have that feature in ccsdspy, but I can as well encapsulate the lines you gave in a function to make my code lighter. That will work for me. Thanks @ddasilva
Np. It's not a huge deal either way, if it's useful for you to have it this way then I'll accept a pull request. Just call it load(..., reset_file_obj=False)
and make sure it has proper doc + tests.
That would be easy to implement in the _load function.
It is needed when the same stream is parsed multiple times, in my case, for 1. decision_packet (when different packets definitions can be used with the same APID), 2. calculate a CRC (see discussion https://github.com/CCSDSPy/ccsdspy/discussions/108#discussioncomment-8425180)
That could be optional with an argument 'return_file_where_it_was' default to False to make the code backward compatible ?
Let me know, your thoughts on that.