dtcooper / python-fitparse

Python library to parse ANT/Garmin .FIT files
http://pythonhosted.org/fitparse/
MIT License
738 stars 184 forks source link

Ignore developer data errors by passing check_developer_data=False #128

Closed AartGoossens closed 3 years ago

AartGoossens commented 3 years ago

Fixes #124

AartGoossens commented 3 years ago

The PR looks more complex than it actually is because I pulled some existing code into new methods for DRY purposes and needed to pass the init keyword argument "check_developer_data" down to the relevant parent class.

The end goal is that you're able to do something like this to ignore errors raised by developer data that was not initialized correctly by "developer_data_id" or "field_description" messages:

fitfile = FitFile("fit/file/with/erroneous/developer/data.fit", check_developer_data=False)

One thing in this PR that I am not 100% sure about is the use of BASE_TYPE_BYTE as the default type for a DevField that is not initialized correctly. Could there be side effects of this? E.g. does this BASE_TYPE_BYTE assume a certain message length that could be different from the actual developer data message?

Also: Should I add documentation for this functionality (either in the README or api docs)? I could not find an obvious place to document a small feature like this.