def load_all(): if(not os.path.isfile("recipes/.git")): logger.warning("Recipes git submodule not checked out ... lets do that for you"); bashexec("git submodule update --init --recursive") logger.info("Recipe clone finished..."); global_recipes.clear(); files = os.listdir("recipes"); recipes = []; v.print_v(v.INFO, "Loading recipes ...") for f in files: if(re.match("[\w\d_-]+.lwr$", f)): recipes.append(f[:-4]); for r in recipes: if not global_recipes.has_key(r): try: global_recipes[r] = recipe(r); except: v.print_v(v.WARN, "Failed to load recipe {0}".format(r)) global_recipes['all'] = recipe('all') global_recipes['all'].category = "pseudo" global_recipes['all'].depends.extend(recipes) v.print_v(v.PDEBUG, "Loading recipes ... done")
def load_all(): if (not os.path.isfile("recipes/.git")): logger.warning( "Recipes git submodule not checked out ... lets do that for you") bashexec("git submodule update --init --recursive") logger.info("Recipe clone finished...") global_recipes.clear() files = os.listdir("recipes") recipes = [] v.print_v(v.INFO, "Loading recipes ...") for f in files: if (re.match("[\w\d_-]+.lwr$", f)): recipes.append(f[:-4]) for r in recipes: if not global_recipes.has_key(r): try: global_recipes[r] = recipe(r) except: v.print_v(v.WARN, "Failed to load recipe {0}".format(r)) global_recipes['all'] = recipe('all') global_recipes['all'].category = "pseudo" global_recipes['all'].depends.extend(recipes) v.print_v(v.PDEBUG, "Loading recipes ... done")
def load_all(): global_recipes.clear(); files = os.listdir("recipes"); recipes = []; print "Loading recipes ..." for f in files: if(re.match("[\w\d_-]+.lwr$", f)): recipes.append(f[:-4]); for r in recipes: if not global_recipes.has_key(r): global_recipes[r] = recipe(r); global_recipes['all'] = recipe('all') global_recipes['all'].category = "pseudo" global_recipes['all'].depends.extend(recipes) print "Loading recipes ... done"
def load_all(): global_recipes.clear() files = os.listdir("recipes") recipes = [] print "Loading recipes ..." for f in files: if (re.match("[\w\d_-]+.lwr$", f)): recipes.append(f[:-4]) for r in recipes: if not global_recipes.has_key(r): global_recipes[r] = recipe(r) global_recipes['all'] = recipe('all') global_recipes['all'].category = "pseudo" global_recipes['all'].depends.extend(recipes) print "Loading recipes ... done"
def load_all(): global_recipes.clear() files = os.listdir("recipes") recipes = [] v.print_v(v.INFO, "Loading recipes ...") for f in files: if (re.match("[\w\d_-]+.lwr$", f)): recipes.append(f[:-4]) for r in recipes: if not global_recipes.has_key(r): try: global_recipes[r] = recipe(r) except: v.print_v(v.WARN, "Failed to load recipe {0}".format(r)) global_recipes['all'] = recipe('all') global_recipes['all'].category = "pseudo" global_recipes['all'].depends.extend(recipes) v.print_v(v.PDEBUG, "Loading recipes ... done")
def load_all(): global_recipes.clear(); files = os.listdir("recipes"); recipes = []; v.print_v(v.INFO, "Loading recipes ...") for f in files: if(re.match("[\w\d_-]+.lwr$", f)): recipes.append(f[:-4]); for r in recipes: if not global_recipes.has_key(r): try: global_recipes[r] = recipe(r); except: v.print_v(v.WARN, "Failed to load recipe {0}".format(r)) global_recipes['all'] = recipe('all') global_recipes['all'].category = "pseudo" global_recipes['all'].depends.extend(recipes) v.print_v(v.PDEBUG, "Loading recipes ... done")
# -*- coding: utf-8 -*- from recipe import * from transformation import recipe_transform import re import json import requests as r from bs4 import BeautifulSoup from fractions import Fraction f = open('results.txt','w') test = recipe('http://allrecipes.com/recipe/47397/cashew-avocado-chicken-salad') test.scrape() test.parseIngredients() test.rec_transform() f.write('INGREDIENTS') f.write('\n') for ing in test.ingredients: des = ing.descriptors meas = ing.measurement name = ing.name prep = ing.preparations quant = ing.quantity #quant + measure + prep + des + name sentence = '' sentence += str(quant) + ' ' if len(meas) != 0: sentence += meas sentence += ' ' for p in prep: sentence += (p + ' ')