Food menu parsing stuff assumes data is for dining commons
simon-andrews opened this issue · 1 comments
Dining commons have really nice menus that give you all sorts of nutritional information and ingredients and stuff. We take advantage of this to give users a whole bunch of useful information:
umass-toolkit/umass_toolkit/dining_utils.py
Lines 35 to 59 in 3a78af4
Unfortunately, non-DC locations do not do this, and basically just have plain text menus. We should handle this.
I'm not sure what I think is the best way to handle this is. My current idea is maybe a get_dc_menu function, separate from get_menu. This could be confusing though because getting DC menus is probably going to be the more useful and more commonly used feature, so I don't like making it the "special case."
I dunno, thoughts?
I think separate functions is good. I was toying with the idea of get_menu
having a different response depending on the ID it receives (list for DC locations, string for non-DC locations) but I think a predictable return type for each function is important.
We should probably have a location_is_dc
function to help determine if an ID corresponds to a DC or non-DC location and use this to raise errors accordingly.
So users would write something like:
def my_dc_function(id):
try:
menu = get_dc_menu(id)
do_something(menu)
except ValueError:
print('ID does not correspond to a DC location')
As for the names, I agree that get_menu
could be too vague since it only applies to non-DC locations.
Some potential ideas:
get_dc_menu
andget_non_dc_menu
get_parsed_menu
andget_raw_menu