coddingtonbear / python-myfitnesspal

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

AssertionError processing a day without data #102

Closed mwarrildt closed 4 years ago

mwarrildt commented 4 years ago

Hi I am issuing a myfitnesspal_client call to get_date(yr, mn, dy) for a date that has no data and getting this error.

Traceback (most recent call last):
  File "./getData.py", line 83, in <module>
    print (day)
  File "/usr/local/lib/python3.7/site-packages/myfitnesspal/day.py", line 110, in __str__
    return f"{date_str} {self.totals}"
  File "/usr/local/lib/python3.7/site-packages/myfitnesspal/day.py", line 62, in totals
    assert self._totals
AssertionError

I'm very new to python, so apologies up front if I'm missing something obvious.

In the past, I checked bool(day.totals) to weed out these no-data-days. I've been trying to test different bits in the day object but without success,

tia Mark

coddingtonbear commented 4 years ago

Oo; that's an excellent catch and definitely caused by some changes I made this weekend. I'll see if I can sort out a patch later today.

mwarrildt commented 4 years ago

Thank you

On Mon, Jul 6, 2020 at 7:16 PM Adam Coddington notifications@github.com wrote:

Oo; that's an excellent catch and definitely caused by some changes I made this weekend. I'll see if I can sort out a patch later today.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/coddingtonbear/python-myfitnesspal/issues/102#issuecomment-654509726, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALSQEVMOXOJLQSJ45KX5YEDR2JLOBANCNFSM4OSA4YIQ .

coddingtonbear commented 4 years ago

Fixed in 6548ed8aab2f46a71007bcbdad53db0f6ba6f792 (v 1.16.1); thanks for the heads-up about the problem @mwarrildt .

Cheers!