Esempio n. 1
0
    def ajouter(self):
        """Attention aux unités. Dans la base xml la couleur est en srm, dans la
        liste de la base la couleur est convertie en EBC"""
        f = Fermentable()
        f.name = self.ui.lineEditNom.text()
        f.fyield = self.ui.spinBoxRendmt.value()
        self.ui.radioButtonSRM.setChecked(True)
        f.color = self.ui.spinBoxCouleur.value() * 1.97

        if self.ui.comboBoxType.currentIndex() is 0:
            f.type = model.constants.FERMENTABLE_TYPE_GRAIN
        elif self.ui.comboBoxType.currentIndex() is 1:
            f.type = model.constants.FERMENTABLE_TYPE_EXTRACT
        elif self.ui.comboBoxType.currentIndex() is 2:
            f.type = model.constants.FERMENTABLE_TYPE_DRY_EXTRACT
        elif self.ui.comboBoxType.currentIndex() is 3:
            f.type = model.constants.FERMENTABLE_TYPE_SUGAR
        elif self.ui.comboBoxType.currentIndex() is 4:
            f.type = model.constants.FERMENTABLE_TYPE_ADJUNCT

        if self.ui.comboBoxReco.currentIndex() is 0:
            f.useAfterBoil = False
        else:
            f.useAfterBoil = True
        ImportBase.addFermentable(f)
        self.setModel()
Esempio n. 2
0
def importBSMXFermentable(data):
    fermentable = Fermentable()
    fermentable.name = data.find('F_G_NAME').text
    # 1 oz = 28.3495231 gr
    fermentable.amount = float(data.find('F_G_AMOUNT').text)*28.3495231
    fermentable.fyield = float(data.find('F_G_YIELD').text)
    # 1 SRM = 1.97 EBC
    fermentable.color = float(data.find('F_G_COLOR').text)*1.97
    fermentable.recommendMash = data.find('F_G_RECOMMEND_MASH').text == '1'
    fermentable.useAfterBoil = data.find('F_G_ADD_AFTER_BOIL').text == '1'
    bsmx_type_grain = {
        '0': model.constants.FERMENTABLE_TYPE_GRAIN,
        '1': model.constants.FERMENTABLE_TYPE_EXTRACT,
        '2': model.constants.FERMENTABLE_TYPE_SUGAR,
        '3': model.constants.FERMENTABLE_TYPE_ADJUNCT,
        '4': model.constants.FERMENTABLE_TYPE_DRY_EXTRACT
    }
    # If the fermentable type is not known, we assume it is sugar
    fermentable.type = bsmx_type_grain.get(data.find('F_G_TYPE').text, model.constants.FERMENTABLE_TYPE_SUGAR)
    return fermentable
Esempio n. 3
0
def importBSMXFermentable(data):
    fermentable = Fermentable()
    fermentable.name = data.find("F_G_NAME").text
    # 1 oz = 28.3495231 gr
    fermentable.amount = float(data.find("F_G_AMOUNT").text) * 28.3495231
    fermentable.fyield = float(data.find("F_G_YIELD").text)
    # 1 SRM = 1.97 EBC
    fermentable.color = float(data.find("F_G_COLOR").text) * 1.97
    fermentable.recommendMash = data.find("F_G_RECOMMEND_MASH").text == "1"
    fermentable.useAfterBoil = data.find("F_G_ADD_AFTER_BOIL").text == "1"
    bsmx_type_grain = {
        "0": model.constants.FERMENTABLE_TYPE_GRAIN,
        "1": model.constants.FERMENTABLE_TYPE_EXTRACT,
        "2": model.constants.FERMENTABLE_TYPE_SUGAR,
        "3": model.constants.FERMENTABLE_TYPE_ADJUNCT,
        "4": model.constants.FERMENTABLE_TYPE_DRY_EXTRACT,
    }
    # If the fermentable type is not known, we assume it is sugar
    fermentable.type = bsmx_type_grain.get(data.find("F_G_TYPE").text, model.constants.FERMENTABLE_TYPE_SUGAR)
    return fermentable
Esempio n. 4
0
def importBSMXFermentable(data):
    fermentable = Fermentable()
    fermentable.name = data.find('F_G_NAME').text
    # 1 oz = 28.3495231 gr
    fermentable.amount = float(data.find('F_G_AMOUNT').text) * 28.3495231
    fermentable.fyield = float(data.find('F_G_YIELD').text)
    # 1 SRM = 1.97 EBC
    fermentable.color = float(data.find('F_G_COLOR').text) * 1.97
    fermentable.recommendMash = data.find('F_G_RECOMMEND_MASH').text == '1'
    fermentable.useAfterBoil = data.find('F_G_ADD_AFTER_BOIL').text == '1'
    bsmx_type_grain = {
        '0': model.constants.FERMENTABLE_TYPE_GRAIN,
        '1': model.constants.FERMENTABLE_TYPE_EXTRACT,
        '2': model.constants.FERMENTABLE_TYPE_SUGAR,
        '3': model.constants.FERMENTABLE_TYPE_ADJUNCT,
        '4': model.constants.FERMENTABLE_TYPE_DRY_EXTRACT
    }
    # If the fermentable type is not known, we assume it is sugar
    fermentable.type = bsmx_type_grain.get(
        data.find('F_G_TYPE').text, model.constants.FERMENTABLE_TYPE_SUGAR)
    return fermentable
Esempio n. 5
0
def importBeerXMLFermentable(data):
    fermentable = Fermentable()

    for child in data:
        if 'NAME' == child.tag:
            fermentable.name = child.text
        elif 'AMOUNT' == child.tag:
            fermentable.amount = 1000 * (float(child.text))
        elif 'TYPE' == child.tag:
            if 'Grain' == child.text:
                fermentable.type = model.constants.FERMENTABLE_TYPE_GRAIN
            elif 'Sugar' == child.text:
                fermentable.type = model.constants.FERMENTABLE_TYPE_SUGAR
            elif 'Extract' == child.text:
                fermentable.type = model.constants.FERMENTABLE_TYPE_EXTRACT
            elif 'Dry Extract' == child.text:
                fermentable.type = model.constants.FERMENTABLE_TYPE_DRY_EXTRACT
            elif 'Adjunct' == child.text:
                fermentable.type = model.constants.FERMENTABLE_TYPE_ADJUNCT
            else:
                logger.warn(
                    "Unkown fermentable type '%', assuming 'Sugar' by default",
                    child.text
                )
                fermentable.type = model.constants.FERMENTABLE_TYPE_SUGAR
        elif 'YIELD' == child.tag:
            fermentable.fyield = float(child.text)
        elif 'RECOMMEND_MASH' == child.tag:
            fermentable.recommendMash = child.text
        elif 'COLOR' == child.tag:
            # ATTENTION ! le format BeerXML utilise des unités SRM !
            # srm*1.97 =ebc
            fermentable.color = float(child.text) * 1.97
        elif 'ADD_AFTER_BOIL' == child.tag:
            if child.text == 'FALSE':
                fermentable.useAfterBoil = False
            elif child.text == 'TRUE':
                fermentable.useAfterBoil = True

    return fermentable
Esempio n. 6
0
def importBeerXMLFermentable(data):
    fermentable = Fermentable()

    for child in data:
        if 'NAME' == child.tag:
            fermentable.name = child.text
        elif 'AMOUNT' == child.tag:
            fermentable.amount = 1000*(float(child.text))
        elif 'TYPE' == child.tag:
            if 'Grain' == child.text:
                fermentable.type = model.constants.FERMENTABLE_TYPE_GRAIN
            elif 'Sugar' == child.text:
                fermentable.type = model.constants.FERMENTABLE_TYPE_SUGAR
            elif 'Extract' == child.text:
                fermentable.type = model.constants.FERMENTABLE_TYPE_EXTRACT
            elif 'Dry Extract' == child.text:
                fermentable.type = model.constants.FERMENTABLE_TYPE_DRY_EXTRACT
            elif 'Adjunct' == child.text:
                fermentable.type = model.constants.FERMENTABLE_TYPE_ADJUNCT
            else:
                logger.warn ("Unkown fermentable type '%', assuming 'Sugar' by default", child.text)
                fermentable.type = model.constants.FERMENTABLE_TYPE_SUGAR
        elif 'YIELD' == child.tag:
            fermentable.fyield = float(child.text)
        elif 'RECOMMEND_MASH' == child.tag:
            fermentable.recommendMash = child.text
        elif 'COLOR' == child.tag:
            #ATTENTION ! le format BeerXML utilise des unités SRM !
            #srm*1.97 =ebc
            fermentable.color = float(child.text)*1.97
        elif 'ADD_AFTER_BOIL' == child.tag:
            if child.text == 'FALSE' :
                fermentable.useAfterBoil = False
            elif child.text == 'TRUE':
                fermentable.useAfterBoil = True

    return fermentable
Esempio n. 7
0
def importDictRecipe(dic):
    logger.debug("Start parsing dict")

    recipe = Recipe()
    recipe.path = dic['path']
    recipe.name = dic['name']
    recipe.brewer = dic['brewer']
    recipe.style = dic['style']
    if dic['type'] == "All Grain":
        recipe.type = RECIPE_TYPE_ALL_GRAIN
    elif dic['type'] == "Extract":
        recipe.type = RECIPE_TYPE_EXTRACT
    elif recipe.type == "Partial Mash":
        recipe.type = RECIPE_TYPE_PARTIAL_MASH

    recipe.volume = dic['volume']
    recipe.boil = dic['boilTime']
    recipe.efficiency = dic['efficiency']

    for hop_dic in dic['hops']:
        hop = Hop()
        hop.name = hop_dic['name']

        if hop_dic['form'] == "Pellet":
            hop.form = HOP_FORM_PELLET
        elif hop_dic['form'] == "Leaf":
            hop.form = HOP_FORM_LEAF
        elif hop_dic['form'] == "Plug":
            hop.form = HOP_FORM_PLUG
        hop.alpha = hop_dic['alpha']
        hop.use = hop_dic['use']
        hop.time = hop_dic['time']
        hop.amount = hop_dic['amount']
        recipe.listeHops.append(hop)

    for f_dic in dic['fermentables']:
        f = Fermentable()
        f.name = f_dic['name']
        f.type = f_dic['type']
        f.fyield = f_dic['fyield']
        f.color = f_dic['color']
        f.amount = f_dic['amount']
        if f_dic['afterBoil'] == 'TRUE':
            f.useAfterBoil = True
        else:
            f.useAfterBoil = False
        f.recommendMash = f_dic['recoMash']
        recipe.listeFermentables.append(f)

    for y_dic in dic['yeasts']:
        y = Yeast()
        y.name = y_dic['name']
        y.productId = y_dic['product_id']
        y.labo = y_dic['labo']
        y.form = y_dic['form']
        y.attenuation = y_dic['attenuation']
        recipe.listeYeasts.append(y)

    for m_dic in dic['miscs']:
        m = Misc()
        m.name = m_dic['name']
        m.amount = m_dic['amount']
        m.type = m_dic['type']
        m.use = m_dic['use']
        m.time = m_dic['time']
        recipe.listeMiscs.append(m)

    mash_dic = dic['mashProfile']
    recipe.mash.name = mash_dic['name']
    recipe.mash.ph = mash_dic['ph']
    recipe.mash.spargeTemp = mash_dic['sparge']
    recipe.mash.tunTemp = mash_dic['tunTemp']

    for s_dic in mash_dic['steps']:
        s = MashStep()
        s.name = s_dic['name']
        s.time = s_dic['time']
        s.temp = s_dic['temp']
        s.type = s_dic['type']
        recipe.listeMashSteps.append(s)
    recipe.recipeNotes = dic['notes']

    return recipe