コード例 #1
0
ファイル: app.py プロジェクト: timpara/gimme-food
def run_app(number_of_recipes, config, ingredient, debug):
    conf = read_config(config)
    log = get_logger(debug, conf["log_file"])
    print_banner(__version__)
    log.info(
        f"gimme-food started - version: {__version__}, config: {config}, " +
        f"number of recipes: {number_of_recipes}, ingredient: {ingredient}, debug: {debug}"
    )
    log.info(f"config values: {conf}")
    try:
        recipe_list = list(make_recipe_db(conf["recipe_folder"]))
    except RecipeNotInProperJsonFormat as e:
        log.error(e)
        sys.exit()
    recipe_picker = RecipePicker(recipe_list, number_of_recipes, ingredient)
    chosen_recipes = recipe_picker.get_recipes()
    present_result(chosen_recipes)
    log.info("gimme-food complete")
コード例 #2
0
ファイル: gimme_food_app.py プロジェクト: matrulda/gimme-food
def run_app(number_of_recipes, config, ingredient, debug):
    conf = read_config(config)
    log = get_logger(debug, conf["log_file"])
    print_banner(__version__)
    print_safe_config = {k: v for k, v in conf.items() if k != "secret"}
    log.info(
        f"gimme-food started - version: {__version__}, config: {print_safe_config}, "
        +
        f"number of recipes: {number_of_recipes}, ingredient: {ingredient}, debug: {debug}"
    )
    try:
        recipe_list = make_recipe_db(conf["recipe_folder"], number_of_recipes)
    except (RecipeNotInProperJsonFormat, NotEnoughRecipesInDatabase,
            InconsistentBD) as e:
        log.error(e)
        sys.exit()
    recipe_picker = RecipePicker(recipe_list, number_of_recipes, ingredient)
    chosen_recipes = recipe_picker.get_recipes()
    present_result(chosen_recipes)
    log.info("gimme-food complete")
コード例 #3
0
def test_one_ingredient(recipe_list):
    recipe_picker = RecipePicker(recipe_list, 1, ("Jordnötssmör",))
    chosen_recipes = recipe_picker.get_recipes()
    assert len(chosen_recipes) == 1
    assert chosen_recipes[0].name == "Fruktig kokosmjölksgryta"
コード例 #4
0
def test_one_ingredient_two_recipes(recipe_list):
    recipe_picker = RecipePicker(recipe_list, 2, ("Jordnötssmör",))
    chosen_recipes = recipe_picker.get_recipes()
    assert len(chosen_recipes) == 2