def importBSMXHop(data): hop = Hop() hop.name = data.find('F_H_NAME').text # 1 oz = 28.3495231 gr hop.amount = float(data.find('F_H_AMOUNT').text) * 28.3495231 hop.alpha = float(data.find('F_H_ALPHA').text) bsmx_hop_form = { '0': model.constants.HOP_FORM_LEAF, '1': model.constants.HOP_FORM_PELLET, '2': model.constants.HOP_FORM_PLUG } hop.form = bsmx_hop_form.get( data.find('F_H_TYPE').text, model.constants.HOP_FORM_LEAF) bsmx_hop_usage = { '0': model.constants.HOP_USE_BOIL, '1': model.constants.HOP_USE_DRY_HOP, '2': model.constants.HOP_USE_FIRST_WORT, '3': model.constants.HOP_USE_MASH, '4': model.constants.HOP_USE_AROMA } hop.use = bsmx_hop_usage.get( data.find('F_H_USE').text, model.constants.HOP_USE_BOIL) if hop.use == model.constants.HOP_USE_DRY_HOP: hop.time = float(data.find('F_H_DRY_HOP_TIME').text) else: hop.time = float(data.find('F_H_BOIL_TIME').text) return hop
def importBSMXHop(data): hop = Hop() hop.name = data.find('F_H_NAME').text # 1 oz = 28.3495231 gr hop.amount = float(data.find('F_H_AMOUNT').text)*28.3495231 hop.alpha = float(data.find('F_H_ALPHA').text) bsmx_hop_form = { '0': model.constants.HOP_FORM_LEAF, '1': model.constants.HOP_FORM_PELLET, '2': model.constants.HOP_FORM_PLUG } hop.form = bsmx_hop_form.get(data.find('F_H_TYPE').text, model.constants.HOP_FORM_LEAF) bsmx_hop_usage = { '0': model.constants.HOP_USE_BOIL, '1': model.constants.HOP_USE_DRY_HOP, '2': model.constants.HOP_USE_FIRST_WORT, '3': model.constants.HOP_USE_MASH, '4': model.constants.HOP_USE_AROMA } hop.use = bsmx_hop_usage.get(data.find('F_H_USE').text, model.constants.HOP_USE_BOIL) if hop.use == model.constants.HOP_USE_DRY_HOP: hop.time = float(data.find('F_H_DRY_HOP_TIME').text) else: hop.time = float(data.find('F_H_BOIL_TIME').text) return hop
def importBSMXHop(data): hop = Hop() hop.name = data.find("F_H_NAME").text # 1 oz = 28.3495231 gr hop.amount = float(data.find("F_H_AMOUNT").text) * 28.3495231 hop.alpha = float(data.find("F_H_ALPHA").text) bsmx_hop_form = { "0": model.constants.HOP_FORM_LEAF, "1": model.constants.HOP_FORM_PELLET, "2": model.constants.HOP_FORM_PLUG, } hop.form = bsmx_hop_form.get(data.find("F_H_TYPE").text, model.constants.HOP_FORM_LEAF) bsmx_hop_usage = { "0": model.constants.HOP_USE_BOIL, "1": model.constants.HOP_USE_DRY_HOP, "2": model.constants.HOP_USE_FIRST_WORT, "3": model.constants.HOP_USE_MASH, "4": model.constants.HOP_USE_AROMA, } hop.use = bsmx_hop_usage.get(data.find("F_H_USE").text, model.constants.HOP_USE_BOIL) if hop.use == model.constants.HOP_USE_DRY_HOP: hop.time = float(data.find("F_H_DRY_HOP_TIME").text) else: hop.time = float(data.find("F_H_BOIL_TIME").text) return hop
def ajouter(self): h = Hop() h.name = self.ui.lineEditNom.text() h.alpha = self.ui.spinBoxAlpha.value() if self.ui.comboBoxForme.currentIndex() is 0: h.form = model.constants.HOP_FORM_LEAF elif self.ui.comboBoxForme.currentIndex() is 1: h.form = model.constants.HOP_FORM_PELLET elif self.ui.comboBoxForme.currentIndex() is 2: h.form = model.constants.HOP_FORM_PLUG else: h.form = model.constants.HOP_FORM_LEAF ImportBase.addHop(h) self.setModel()
def importBeerXMLHop(data): hop = Hop() for child in data: if 'NAME' == child.tag: hop.name = child.text elif 'AMOUNT' == child.tag: hop.amount = 1000 * (float(child.text)) elif 'FORM' == child.tag: if 'Pellet' == child.text: hop.form = model.constants.HOP_FORM_PELLET elif 'Leaf' == child.text: hop.form = model.constants.HOP_FORM_LEAF elif 'Plug' == child.text: hop.form = model.constants.HOP_FORM_PLUG else: logger.warn( "Unkown hop form '%s', assuming 'Pellet' by default", child.text ) hop.form = model.constants.HOP_FORM_PELLET elif 'TIME' == child.tag: hop.time = float(child.text) elif 'ALPHA' == child.tag: hop.alpha = float(child.text) elif 'USE' == child.tag: if 'Boil' == child.text: hop.use = model.constants.HOP_USE_BOIL elif 'Dry Hop' == child.text or 'Dry Hopping' == child.text: hop.use = model.constants.HOP_USE_DRY_HOP elif 'Mash' == child.text: hop.use = model.constants.HOP_USE_MASH elif 'First Wort' == child.text: hop.use = model.constants.HOP_USE_FIRST_WORT elif 'Aroma' == child.text: hop.use = model.constants.HOP_USE_AROMA else: logger.warn( "Unkown hop use '%s', assuming 'Boil' by default", child.text ) hop.use = model.constants.HOP_USE_BOIL return hop
def importBeerXMLHop(data): hop = Hop() for child in data: if 'NAME' == child.tag : hop.name = child.text elif 'AMOUNT' == child.tag : hop.amount = 1000*(float(child.text)) elif 'FORM' == child.tag : if 'Pellet' == child.text: hop.form = model.constants.HOP_FORM_PELLET elif 'Leaf' == child.text: hop.form = model.constants.HOP_FORM_LEAF elif 'Plug' == child.text: hop.form = model.constants.HOP_FORM_PLUG else : logger.warn ("Unkown hop form '%s', assuming 'Pellet' by default", child.text) hop.form = model.constants.HOP_FORM_PELLET elif 'TIME' == child.tag : hop.time = float(child.text) elif 'ALPHA' == child.tag : hop.alpha = float(child.text) elif 'USE' == child.tag: if 'Boil' == child.text : hop.use = model.constants.HOP_USE_BOIL elif 'Dry Hop' == child.text or 'Dry Hopping' == child.text: hop.use = model.constants.HOP_USE_DRY_HOP elif 'Mash' == child.text: hop.use = model.constants.HOP_USE_MASH elif 'First Wort' == child.text: hop.use = model.constants.HOP_USE_FIRST_WORT elif 'Aroma' == child.text: hop.use = model.constants.HOP_USE_AROMA else : logger.warn ("Unkown hop use '%s', assuming 'Boil' by default", child.text) hop.use = model.constants.HOP_USE_BOIL if hop.use == 'Dry Hop': hop.time /= 24*60 return hop
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