coddingtonbear / python-myfitnesspal

Access your meal tracking data stored in MyFitnessPal programatically
MIT License
794 stars 136 forks source link

Client._get_numeric returns 0 if string doesn't contain 'st' or 'lb' units #76

Closed gg closed 5 years ago

gg commented 5 years ago

The recent commit for #30 introduced a bug: _get_numeric returns 0 if the string doesn't contain 'st' or 'lb' units (e.g. _get_numeric('120') returns 0).

This occurs because the BRITISH_UNIT_MATCHER regex matches any string.

One way to fix this is to change the regex to only match strings that contain 'st':

(?:(?P<st>\d+) st)\W*(?:(?P<lbs>\d+) lb)?

You can test the regex here: https://regex101.com/r/HbAEZi/1

coddingtonbear commented 5 years ago

Whoops; good call.

coddingtonbear commented 5 years ago

Fixed as part of 1.13.3!