def item_add(self):
     try:
         for n in range(99):
             name = "Rezept %d" % (n+1)
             Recipe.getByName(name)
     except KeyError:
         pass
     self.master.screen_push(AlphaScreen(self.master, label="Name für neues Rezept:", defval=name, callback=self._item_add_finish))
Exemple #2
0
def test_save_recipe(mock_json_dump):
    """Test saving a recipe works."""
    expected_recipes = read_recipes()
    recipe = Recipe("new recipe", ["banana", "apple"])
    recipe.save()
    expected_recipes.append(recipe)
    mock_json_dump.assert_called_once()
    assert mock_json_dump.call_args[0][0] == [
        r.to_json() for r in expected_recipes
    ]
Exemple #3
0
 def load_configs(self):
     try:
         with open(os.path.expanduser("~/.tikibot.yaml"), "r") as f:
             confs = yaml.safe_load(f)
     except FileNotFoundError:
         confs = yaml.load(self.get_resource("tikibot_configs.yaml"))
     self.passcode = confs.get('passcode', '8888')
     self.use_metric = confs.get('use_metric', False)
     SupplyFeed.fromDict(confs)
     Recipe.fromDict(confs)
Exemple #4
0
 def update_buttons(self):
     for btn in self.buttons:
         btn.forget()
         btn.destroy()
     types = Recipe.getTypeNames()
     colsarr = [1, 2, 3, 2, 3, 3, 4]
     maxcols = colsarr[len(types)]
     col, row = 1, 1
     for type_ in types:
         img = self.master.get_image(Recipe.getTypeIcon(type_))
         cmd = lambda typ=type_: self.handle_type_button(typ)
         btn = Button(self,
                      text=type_,
                      compound=TOP,
                      image=img,
                      command=cmd,
                      width=160)
         btn.grid(column=col, row=row, padx=5, pady=5)
         self.buttons.append(btn)
         col += 1
         if col > maxcols:
             col = 1
             row += 1
             self.rowconfigure(row, weight=0)
     img = self.master.get_image("IngredientsIcon.gif")
     btn = Button(self,
                  text="By Ingredient",
                  compound=TOP,
                  image=img,
                  command=self.handle_button_ingredients,
                  width=160)
     btn.grid(column=col, row=row, padx=5, pady=5)
     self.buttons.append(btn)
     confbtn = RectButton(self,
                          text="\u2699",
                          command=self.handle_button_conf,
                          width=15,
                          height=20)
     confbtn.grid(column=maxcols,
                  row=row,
                  columnspan=2,
                  rowspan=2,
                  sticky=S + E)
     self.buttons.append(confbtn)
     self.columnconfigure(0, weight=1)
     for col in range(maxcols):
         self.columnconfigure(col + 1, weight=0)
     self.columnconfigure(maxcols + 1, weight=1)
     self.columnconfigure(maxcols + 2, weight=0)
     self.columnconfigure(maxcols + 3, weight=0)
     self.rowconfigure(0, weight=1)
     self.rowconfigure(1, weight=0)
     self.rowconfigure(row + 1, weight=1)
     self.rowconfigure(row + 2, weight=0)
     self.rowconfigure(row + 3, weight=0)
Exemple #5
0
class RecipeTests(unittest.TestCase):
    """Contain methods to test creating, updating and deleting"""
    def setUp(self):
        """set up important variables that will be available within all methods"""
        self.recipe = Recipe()
        self.existing_recipe = self.recipe.create('Grilled Chicken', 'chicken',
                                                  'grill the chicken')

    def test_no_empty_field(self):
        """test for successful recipe creation"""
        new = self.recipe.create('Chapati', 'chapo', 'fry the chapati')
        self.assertEqual(new, "Recipe created succesfully")

    def test_empty_field(self):
        """test for empty field in recipe creation"""
        new = self.recipe.create('Grilled Chicken', '', 'grill the chicken')
        self.assertEqual(new, "Please fill in all fields")

    def test_existing_title(self):
        """test for recipe creation using an existing title"""
        new = self.recipe.create('Grilled Chicken', 'chicken',
                                 'grill the chicken')
        self.assertEqual(new, "Title already exists")

    def test_successful_update(self):
        """test for successful recipe update"""
        update = self.recipe.update('Grilled Chicken', 'lunch manenos',
                                    'grill the chicken')
        self.assertEqual(update, "Sucessfully updated")

    def test_empty_update_field(self):
        """test for empty field in recipe update"""
        update = self.recipe.update('', 'lunch manenos', 'grill the chicken')
        self.assertEqual(update, "Please fill in all fields")

    def test_update_non_existing_title(self):
        """test for recipe creation using an existing title"""
        update = self.recipe.update('Homemeade bread', 'bread',
                                    'bake the bread')
        self.assertEqual(update, "Recipe does not exist")

    def test_successful_deletion(self):
        """test for successful recipe deletion"""
        delete = self.recipe.delete('Grilled Chicken')
        self.assertEqual(delete, "Successfully deleted")

    def test_empty_delete_field(self):
        """test for empty field in recipe deletion"""
        delete = self.recipe.delete('')
        self.assertEqual(delete, "Please fill in all fields")

    def test_delete_non_existing(self):
        """test deleting a recipe that does not exist"""
        delete = self.recipe.delete('Sukuma Wiki')
        self.assertEqual(delete, "Recipe does not exist")
Exemple #6
0
 def load_configs(self):
     try:
         with open(os.path.expanduser("~/.tikibot.yaml"), "r") as f:
             confs = yaml.load(f)
     except FileNotFoundError:
         confs = yaml.load(self.get_resource("tikibot_configs.yaml"))
     self.passcode = confs.get('passcode', '8888')
     self.use_metric = confs.get('use_metric', True)
     self.stepsforml = confs.get('stepsforml', "113")
     self.serdevice = confs.get('serdevice', '/dev/ttyUSB0')
     self.bgcolor = confs.get('bgcolor', '#94F92F')
     SupplyFeed.fromDict(confs)
     Recipe.fromDict(confs)
Exemple #7
0
def check_available_recipes():
    """ The function needs to return a list of recipes that could be made with
    the inventory available. The function uses recipe.need_ingrediants(), if
    nothing is returned we add it to the list"""
    c.execute('SELECT * FROM recipes')
    recipes_db = c.fetchall()

    av = []
    for rec in recipes_db:
        r = Recipe(rec[0],cPickle.loads(str(rec[1])))
        if (r.need_ingredients() == []):
            av.append(r)
    
    return av 
Exemple #8
0
 def exportpdf(self):
     #header()
     #footer()
     self.pdf = ExportPdf()
     #recipes = Recipe(self)
     self.pdf.alias_nb_pages()
     self.pdf.add_page()
     self.pdf.set_auto_page_break(0)
     height_of_cell = 5
     page_height = 295
     bottom_margin = 15
     self.pdf.set_font('Times', '', 12)
     types = Recipe.getTypeNames()
     for type_ in types:
         if type_ != 'Extra Schuss':
             self.pdf.set_font('Times', '', 22)
             space_left=page_height-(self.pdf.get_y()+bottom_margin) # space left on page
             if (height_of_cell * 6 > space_left):
                 self.pdf.add_page() # page break
             currentrecipes = Recipe.getRecipesByType(type_)
             number_recipes = 0
             for recipe in currentrecipes:
                 if Recipe.canMake(recipe):
                     number_recipes += 1
             self.pdf.cell(60, 18, type_ + " (" + str(number_recipes) + ")", 0,1, 'C')
             for recipe in currentrecipes:
                 if Recipe.canMake(recipe):
                     name = recipe.getName()
                     apbv = Recipe.getAlcoholPercentByVolume(recipe)
                     if apbv < 0.1:
                         name=name + ' (Alkoholfrei)'
                     else:
                         #alc_warn = "\u2620" * int(100*apbv/100.0/14.0)
                         #alc_warn = "@" * int(100*apbv/100.0/14.0)
                         name = name + " (%.1f%% Alcoholgehalt)" % (apbv)
                         #name = name + " (%.1f%% Volumen-Alcoholgehalt  %s)" % (apbv, alc_warn)
                     self.pdf.set_font('Times', '', 14)
                     space_left=page_height-(self.pdf.get_y()+bottom_margin) # space left on page
                     if (height_of_cell * 2 > space_left):
                         self.pdf.add_page() # page break
                     self.pdf.cell(90, 5, name, 'B',2)
                     self.pdf.cell(10, 5, '         ', 0, 0)
                     currenting=[]
                     for ing in recipe.ingredients:
                         currenting.append(ing.readableDesc())
                         #currenting.append(ing.readableDesc(partial, metric=True))
                     self.pdf.set_font('Times', '', 13)
                     self.pdf.cell(50, 5, ', '.join(currenting), 0, 0)
                     self.pdf.cell(0, 7, '', 0, 1)
     self.pdf.output(os.path.expanduser("~/cocktailkarte.pdf"), 'F')
Exemple #9
0
    def pick_recipe(self):
        # pick random (weighted) dish type
        dish = self._pick_dish()
        # grab search page for type
        resp = req.get(dish.url)
        per_page = 20
        soup = BeautifulSoup(resp.text)
        # count results
        results = soup.find('p', {'class': 'searchResultsCount results'})
        count = int(results.find('span').text.replace(',', ''))
        # calculate number of pages
        pages = ceil(count / 20)
        rating = 0

        while rating < 4:
            # grab random page
            page = random.randint(1, pages)
            resp = req.get(dish.url, params={'Page': page})
            soup = BeautifulSoup(resp.text)
            results = soup.findAll('div', {'class': 'recipe-info'})
            # grab link to random recipe on page
            recipe_num = random.randint(0, len(results) - 1)
            result = results[recipe_num]
            url = 'http://www.allrecipes.com' + result.p.a.get('href')
            # grab the recipe
            try:
                recipe = Recipe(url=url)
                rating = recipe.rating
            except:
                rating = 0

        return recipe
 def _item_add_finish(self, name):
     for typ in type_icons.keys():
         break
     recipe = Recipe(master, typ, name, mixit)
     self.master.save_configs()
     self.update_listbox()
     self.master.screen_pop()
     self.master.screen_push(RecipeEditScreen(self.master, recipe))
 def _get_items(self):
     return [
         {
             "name": recipe.getName(),
             "data": recipe,
         }
         for recipe in sorted(Recipe.getAll(), key=operator.attrgetter('name'))
     ]
Exemple #12
0
 def save_configs(self):
     confs = {
         "conf_version": "1.0.0",
         "passcode": self.passcode,
         "use_metric": self.use_metric,
     }
     confs = SupplyFeed.toDictAll(confs)
     confs = Recipe.toDictAll(confs, metric=self.use_metric)
     with open(os.path.expanduser("~/.tikibot.yaml"), "w") as f:
         f.write(yaml.dump(confs))
 def get_recipe(serialized_recipe_dict):
     """Convert a dict returned by the JSON decoder into a Recipe object."""
     recipe = Recipe(serialized_recipe_dict["name"],
                     serialized_recipe_dict["pos"],
                     serialized_recipe_dict["ingredients"],
                     serialized_recipe_dict["other"],
                     serialized_recipe_dict["lower_bounds"],
                     serialized_recipe_dict["upper_bounds"],
                     serialized_recipe_dict["entry_type"],
                     serialized_recipe_dict["variables"])
     return recipe
Exemple #14
0
    def test_do_not_pick_any_recipe_if_ingredients_requirement_can_not_be_satisfied(
            self):
        days = ['jueves']
        ingredients_list = ['pollo']

        my_meals = [
            Recipe('', 'Puré de calabaza', ['calabaza', 'nata']),
            Recipe('', 'Arroz a la cubana',
                   ['arroz', 'huevo', 'tomate frito']),
        ]
        my_dinners = [
            Recipe('', 'Ensalada de piña', ['lechuga', 'jamón york', 'piña']),
            Recipe('', 'Tortilla de patatas',
                   ['huevos', 'patatas', 'cebolla']),
        ]
        result = create_menu(week_days=days,
                             my_meals=my_meals,
                             my_dinners=my_dinners,
                             ingredients=ingredients_list)

        self.assertEqual(len(result), 0)
Exemple #15
0
 def save_configs(self):
     confs = {
         "conf_version": "1.0.0",
         "passcode": self.passcode,
         "use_metric": self.use_metric,
         "stepsforml": self.stepsforml,
         "serdevice": self.serdevice,
         "bgcolor": self.bgcolor,
     }
     confs = SupplyFeed.toDictAll(confs)
     confs = Recipe.toDictAll(confs, metric=self.use_metric)
     with open(os.path.expanduser("~/.tikibot.yaml"), "w") as f:
         yaml.dump(confs, f)
Exemple #16
0
 def item_del(self, idx, txt, feed):
     self.sel_feed = feed
     recipes = Recipe.getRecipesByFeed(feed)
     if recipes:
         self.master.screen_push(
             NotifyScreen(
                 self.master,
                 text="That feed is currently in use by one or more recipes."
             ))
     else:
         self.master.screen_push(
             SelectScreen(self.master, ["Confirm"],
                          labeltext='Delete feed "%s"?' % txt,
                          callback=self._item_del_finish))
 def item_del(self, idx, txt, feed):
     self.sel_feed = feed
     recipes = Recipe.getRecipesByFeed(feed)
     if recipes:
         self.master.screen_push(
             NotifyScreen(
                 self.master,
                 text=
                 "Diese Zutat wird gerade durch eines oder mehrtere Rezepte verwendet."
             ))
     else:
         self.master.screen_push(
             SelectScreen(self.master, ["Confirm"],
                          labeltext='Lösche Zutat "%s"?' % txt,
                          callback=self._item_del_finish))
Exemple #18
0
 def setUp(self) -> None:
     self.my_meals = [
         Recipe('', 'Raviolis con salsa de berenjena',
                ['berenjenas', 'raviolis', 'parmesano']),
         Recipe('', 'Puré de calabaza', ['calabaza', 'nata']),
         Recipe('', 'Arroz a la cubana',
                ['arroz', 'huevo', 'tomate frito']),
         Recipe('', 'Paella', ['arroz', 'conejo', 'pimientos']),
     ]
     self.my_dinners = [
         Recipe('', 'Ensalada de piña', ['lechuga', 'jamón york', 'piña']),
         Recipe('', 'Sopa de fideos',
                ['caldo de pollo', 'fideos', '4 huevos']),
         Recipe('', 'Tortilla de patatas',
                ['huevos', 'patatas', 'cebolla']),
     ]
from recipes import Recipe, MeasurmentUnitTypes
from .people import alex_kessinger

recipe = Recipe(title='Skirt Steak', creator=[alex_kessinger], recorder=[alex_kessinger], portions=4)

recipe.set_description("""
Around the time that Audrey was born, I started to get interested in grilling. I had spend a fair amount of time cooking,
but I got the urge to grill. Skirt Steak was one of my early success. Most of all because it's simple.

I have head skirt steak prepared via other methods, but grilling, on hardwood charcoal is objectivley better. The smoke
adds an imense amount of flavor to the fatty meat, and that is the seasoning, more then the salt, or the oil.

Skirt steak has unfortunatley been discovered, and so it is expensive. The Berkeley Bowl is selling it for 15.99 a pound.
If you want almost the same experience with a cheaper cut of meat get a butcher steak, or I have heard it refered to as a
hanger steak. It has a serious tendon right down the middle, but just eat around it.

Putting rosemary sticks on the coals, and rubbing the meat with rosemary is a nice addition.
""")

recipe.add_requirements(
  ('A grill, get it hot', ),
  ('Tongs, because the grill will be hot', ),
)


recipe.add_ingredients(
  ('Skirt Steak', 1),
  ('Toasted Seasame Oil', 2, MeasurmentUnitTypes.ounce),
  ('Salt, enough to cover the steak', ),
  ('Pepper, enough to cover the steak', ),
)
Exemple #20
0
 def handle_button_select(self, item):
     feed = SupplyFeed.getByName(item)
     recipes = Recipe.getRecipesByFeed(feed)
     self.master.screen_push(
         RecipeScreen(self.master, recipes,
                      "Select a drink with %s:" % item))
from recipes import Recipe, MeasurmentUnitTypes
from .people import alex_kessinger

recipe = Recipe(title='Roast Chicken and Roast Vegetales', creator=[alex_kessinger], recorder=[alex_kessinger], portions=4)

recipe.set_description("""
I first tried this recipe based on an Alton Brown Recipe. I have made my own additions, and tweaks though.

The key here is that the chiken skin is not water permeable, so if you want the meat to be flavored,
you have to get under the skin. So, by creating a tasty mixture, and the getting it under the skin
you will be able to permeate the meat with flavor.

I like to roast the chiken with potatoes, and vegetables all at once. YMMV.
""")

recipe.add_requirements(
  ('A roast pan, and rack', ),
  ('An oven', ),
)


recipe.add_ingredients(
  ('Fryer Chiken', 1),
  ('Cloves of garlic', 2),
  ('Rosemary, minced', 1, MeasurmentUnitTypes.ounce),
  ('Stick of butter', 1),
  ('Lemon', 1),
  ('Salt', ),
  ('Pepper', ),
  ('Small potatoes, or cut potatoes to 1 1/2 inch', 10),
  ('Cleaned, but not peeled carrots', 6),
Exemple #22
0
def test_print_recipe():
    """Test the string representation of a recipe."""
    recipe = Recipe("Tuna pasta", ingreds)
    assert str(
        recipe) == 'Recipe "Tuna pasta"\n - tuna\n - sweetcorn\n - pasta'
Exemple #23
0
"""Handles the view function of my MVC design pattern"""

from flask import render_template, request, redirect, session, url_for
from app import app
from users import User, all_users
from recipes import Recipe, all_recipes

user = User()
recipe = Recipe()

@app.route('/')
@app.route('/index')
def index():
    """render the home page"""
    return render_template('index.html')


@app.route('/about')
def about():
    """render the about page"""
    return render_template('about.html')


@app.route('/signup', methods=['GET', 'POST'])
def signup():
    """render the registration form and handles user input for registration"""
    if request.method == 'POST':
        email = request.form['email']
        username = request.form['username']
        password = request.form['password']
        confirm_password = request.form['confirmPassword']
 def handle_button_retype(self):
     self.master.screen_push(
         SelectScreen(self.master,
                      Recipe.getPossibleTypeNames(),
                      labeltext="Select the recipe type:",
                      callback=self.retype_complete))
Exemple #25
0
def test_recipe_to_json():
    """Test converting a recipe to JSON format."""
    recipe = Recipe("Tuna pasta", ingreds)
    data = recipe.to_json()
    assert data["name"] == recipe.name
    assert data["ingredients"] == recipe.ingreds
Exemple #26
0
def hot_water(water):
    return Recipe(cook_time=1, r_id=3, ingredients=((water, 50), ))
Exemple #27
0
def test_recipe_from_json():
    """Test creating a recipe from JSON format."""
    orig_recipe = Recipe("Tuna pasta", ingreds)
    new_recipe = Recipe.from_json(orig_recipe.to_json())
    assert new_recipe.name == orig_recipe.name
    assert new_recipe.ingreds == orig_recipe.ingreds
Exemple #28
0
 def handle_button_select(self, item):
     feed = SupplyFeed.getByName(item)
     recipes = Recipe.getRecipesByFeed(feed)
     self.master.screen_push(
         RecipeScreen(self.master, recipes,
                      "Wähle einen Drink mit %s:" % item))
screenManager.add_widget(Trends(name="trends"))

screenManager.add_widget(ShoppingList(name="shoppinglist"))

screenManager.add_widget(ItemShare(name="shareitems"))

screenManager.add_widget(ManagePL(name="managepl"))

screenManager.add_widget(EditCreateProfile(name="editcreateprofile"))

screenManager.add_widget(SetupEditNotification(name="setupeditnotification"))

screenManager.add_widget(UpdatePersonalRecipe(name="updatepersonalrecipe"))

screenManager.add_widget(Recipe(name="recipes"))

screenManager.add_widget(AddRecipe(name="addrecipe"))

screenManager.add_widget(GetRecipe(name="getreccrecipes"))

screenManager.add_widget(ViewRecipe(name="viewrecipe"))

screenManager.add_widget(PersonalRecipe(name='personalrecipe'))

screenManager.add_widget(ViewPersonalRecipe(name='viewpersonalrecipe'))

screenManager.add_widget(AddItem(name="additem"))

screenManager.add_widget(DeleteItem(name="deleteitem"))
Exemple #30
0
def ginger_tea(water, milk, tea_leaves_syrup, ginger_syrup, sugar_syrup):
    return Recipe(cook_time=1,
                  r_id=1,
                  ingredients=((water, 50), (milk, 10), (tea_leaves_syrup, 10),
                               (ginger_syrup, 5), (sugar_syrup, 10)))
Exemple #31
0
def test_create_recipe():
    """Test creating a recipe works as expected."""
    recipe = Recipe("Tuna pasta", ingreds)
    assert recipe.name == "Tuna pasta"
    assert recipe.ingreds == ingreds
Exemple #32
0
 def handle_button_select(self, item):
     recipe = Recipe.getByName(item)
     self.master.screen_push(PourScreen(self.master, recipe))
Exemple #33
0
def hot_milk(milk):
    return Recipe(cook_time=1, r_id=2, ingredients=((milk, 50), ))