Example #1
0
def importBeerXMLMisc(data):
    misc = Misc()

    for child in data:
        if 'NAME' == child.tag:
            misc.name = child.text
        elif 'AMOUNT' == child.tag:
            misc.amount = float(child.text) * 1000
        elif 'TYPE' == child.tag:
            misc.type = child.text
        elif 'TIME' == child.tag:
            try:
                misc.time = float(child.text)
            except ValueError:
                misc.time = 0.0
                logger.debug("misc time attribute is not numeric:%s",
                             child.text)
        elif 'USE' == child.tag:
            if 'Boil' == child.text:
                misc.use = model.constants.MISC_USE_BOIL
            elif 'Mash' == child.text:
                misc.use = model.constants.MISC_USE_MASH
            elif 'Primary' == child.text:
                misc.use = model.constants.MISC_USE_PRIMARY
            elif 'Secondary' == child.text:
                misc.use = model.constants.MISC_USE_SECONDARY
            elif 'Bottling' == child.text:
                misc.use = model.constants.MISC_USE_BOTTLING
            else:
                logger.warn("Unkown misc use '%s', assuming 'Boil' by default",
                            child.text)
                misc.use = model.constants.MISC_USE_BOIL

    return misc
Example #2
0
def importBeerXMLMisc(data):
    misc = Misc()

    for child in data:
        if 'NAME' == child.tag :
            misc.name = child.text
        elif 'AMOUNT' == child.tag :
            misc.amount = float(child.text)*1000
        elif 'TYPE' == child.tag :
            misc.type = child.text
        elif 'TIME' == child.tag:
            try:
                misc.time = float(child.text)
            except ValueError:
                misc.time = 0.0
                logger.debug("misc time attribute is not numeric:%s", child.text)
        elif 'USE' == child.tag:
            if 'Boil' == child.text:
                misc.use = model.constants.MISC_USE_BOIL
            elif 'Mash' == child.text:
                misc.use = model.constants.MISC_USE_MASH
            elif 'Primary' == child.text:
                misc.use = model.constants.MISC_USE_PRIMARY
            elif 'Secondary' == child.text:
                misc.use = model.constants.MISC_USE_SECONDARY
            elif 'Bottling' == child.text:
                misc.use = model.constants.MISC_USE_BOTTLING
            else:
                logger.warn ("Unkown misc use '%s', assuming 'Boil' by default", child.text)
                misc.use = model.constants.MISC_USE_BOIL

    return misc
Example #3
0
def importBSMXMisc(data):
    misc = Misc()
    misc.name = data.find("F_M_NAME").text
    # 1 tsp (US) = 4.92892161458 gr
    misc.amount = float(data.find("F_M_AMOUNT").text) * 4.92892161458
    misc.time = float(data.find("F_M_TIME").text)
    misc.type = data.find("F_M_USE_FOR").text
    bsmx_misc_usage = {"1": model.constants.MISC_USE_BOIL, "5": model.constants.MISC_USE_MASH}
    misc.use = bsmx_misc_usage.get(data.find("F_M_TYPE").text, model.constants.MISC_USE_BOIL)
    return misc
Example #4
0
def importBSMXMisc(data):
    misc = Misc()
    misc.name = data.find('F_M_NAME').text
    # 1 tsp (US) = 4.92892161458 gr
    misc.amount = float(data.find('F_M_AMOUNT').text) * 4.92892161458
    misc.time = float(data.find('F_M_TIME').text)
    misc.type = data.find('F_M_USE_FOR').text
    bsmx_misc_usage = {
        '1': model.constants.MISC_USE_BOIL,
        '5': model.constants.MISC_USE_MASH
    }
    misc.use = bsmx_misc_usage.get(
        data.find('F_M_TYPE').text, model.constants.MISC_USE_BOIL)
    return misc
Example #5
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