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

Fixes tuple index out of range #2

Merged
merged 1 commit into from
Jul 17, 2016
Merged

Fixes tuple index out of range #2

merged 1 commit into from
Jul 17, 2016

Conversation

borgified
Copy link
Contributor

I kept getting these errors:

Exception clipping coupons: tuple index out of range
Traceback (most recent call last):
File "/home/fwiffo/scripts/safeway-coupons/safeway-coupons", line 298, in _clip_coupons
'CC')
File "/home/fwiffo/scripts/safeway-coupons/safeway-coupons", line 197, in _get_coupon_details
coupon_detail.get('prodDsc1', ''))).strip()
IndexError: tuple index out of range

through trial and error, this seemed to fix it

@smkent
Copy link
Owner

smkent commented Jul 2, 2016

I reproduced the error. It looks like the problem is in the format() call on that line where title is set. I'm passing a tuple instead of just leaving the values as function arguments. Changing the ts value passed to _get_coupon_details will result in the wrong details URI being retrieved. Instead, we should just fix the format() call.

Since you found the bug, I'd like to give you credit for it in the commit log. Can you update the request to make that change? Just remove the extra parentheses, i.e.:

title = '{} {} {}'.format(coupon_detail.get('titleDsc1', ''),
                          coupon_detail.get('titleDsc2', ''),
                          coupon_detail.get('prodDsc1', '')).strip()

Let me know if that works for you. Thanks!

@borgified
Copy link
Contributor Author

I've updated the PR with your recommended changes and tested it working. Thank you for taking the time to debug and thank you for this wonderful script!

@smkent
Copy link
Owner

smkent commented Jul 17, 2016

Of course, thanks for the bug report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants