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

Cannot use certain words in ingredients #287

Closed
ockham opened this issue Dec 24, 2012 · 2 comments
Closed

Cannot use certain words in ingredients #287

ockham opened this issue Dec 24, 2012 · 2 comments

Comments

@ockham
Copy link
Collaborator

ockham commented Dec 24, 2012

Converted from SourceForge issue 3037661, submitted by SourceForge user divinenephron on 2010-07-31 21:53:18 UTC.

I am unable to enter an ingredient by the name of "85g watercress leaves". Pressing enter or the "Add" button does nothing, and attempting to rename existing ingredients with this name leads to a reversion to the previous name. Testing has shown that the plural "leaves" is the offending word, and gourmet will accept "85g watercress leave" or "85g watercress leave s".

The following traceback is encountered in the terminal window whenever "leaves" is entered as part of an new ingredient name:

Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/gourmet/reccard.py", line 1120, in quick_add
lambda _args: self.add_ingredient_from_line(txt,
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/gourmet/reccard.py", line 2856, in add_with_undo
widget=rc.ingtree_ui.ingController.imodel
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/gourmet/Undo.py", line 48, in perform
self.action(_self.action_args)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/gourmet/reccard.py", line 2850, in do_it
method()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/gourmet/reccard.py", line 1122, in
group_iter=group_iter)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/gourmet/reccard.py", line 1166, in add_ingredient_from_line
d=self.rg.rd.parse_ingredient(line, conv=self.rg.conv)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/gourmet/backends/db.py", line 1822, in parse_ingredient
if get_key: d['ingkey']=self.km.get_key(i.strip())
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/gourmet/keymanager.py", line 130, in get_key
result = self.look_for_key(txt)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/gourmet/keymanager.py", line 149, in look_for_key
main_txts.extend(defaults.guess_singulars(txt))
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/gourmet/defaults/defaults_en_GB.py", line 696, in guess_singulars
if not wrd in rets: rets.append(wrd)
UnboundLocalError: local variable 'wrd' referenced before assignment

Attempting to edit an ingredient to include the word "leaves" leads to a similar error:

Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/gourmet/reccard.py", line 2397, in ingtree_edited_cb
d['ingkey']=self.rg.rd.km.get_key(text)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/gourmet/keymanager.py", line 130, in get_key
result = self.look_for_key(txt)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/gourmet/keymanager.py", line 149, in look_for_key
main_txts.extend(defaults.guess_singulars(txt))
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/gourmet/defaults/defaults_en_GB.py", line 696, in guess_singulars
if not wrd in rets: rets.append(wrd)
UnboundLocalError: local variable 'wrd' referenced before assignment

I'm not familiar with Gourmet's internals, but suspect that this is something to do with quantity detection based on the fact that "leaves" could be a unit.

Hopefully this isn't a contributing factor to the error, but I'm using my homemade Macports build of gourmet on OSX 10.6. This hasn't been accepted into the Macports SVN yet (http://trac.macports.org/ticket/25698), so a diff of the portfile it is attached.

@pounamu
Copy link
Contributor

pounamu commented May 25, 2014

Adding watercress leaves as an ingredient is possible now. I think this has been fixed.

@pounamu
Copy link
Contributor

pounamu commented Jun 1, 2014

Confirming that this is still a bug for en_GB (but not de_DE). Here's the traceback for "100g watercress leaves" (some line numbers and method names have changed since the bug was first posted):

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/gourmet/reccard.py", line 1124, in quick_add
    lambda *args: self.add_ingredient_from_line(txt,
  File "/usr/local/lib/python2.7/dist-packages/gourmet/reccard.py", line 2835, in add_with_undo
    widget=rc.ingtree_ui.ingController.imodel
  File "/usr/local/lib/python2.7/dist-packages/gourmet/Undo.py", line 48, in perform
    self.action(*self.action_args)
  File "/usr/local/lib/python2.7/dist-packages/gourmet/reccard.py", line 2829, in do_it
    method()
  File "/usr/local/lib/python2.7/dist-packages/gourmet/reccard.py", line 1126, in <lambda>
    group_iter=group_iter)
  File "/usr/local/lib/python2.7/dist-packages/gourmet/reccard.py", line 1170, in add_ingredient_from_line
    d=self.rg.rd.parse_ingredient(line, conv=self.rg.conv)
  File "/usr/local/lib/python2.7/dist-packages/gourmet/backends/db.py", line 1909, in parse_ingredient
    if get_key: d['ingkey']=self.km.get_key(i.strip())
  File "/usr/local/lib/python2.7/dist-packages/gourmet/keymanager.py", line 130, in get_key
    result = self.look_for_key(txt)
  File "/usr/local/lib/python2.7/dist-packages/gourmet/keymanager.py", line 149, in look_for_key
    main_txts.extend(defaults.guess_singulars(txt))
  File "/usr/local/lib/python2.7/dist-packages/gourmet/defaults/defaults_en_GB.py", line 695, in guess_singulars
    if not wrd in rets: rets.append(wrd)
UnboundLocalError: local variable 'wrd' referenced before assignment

@ockham ockham closed this as completed in d1f827d Jun 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants