예제 #1
0
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
예제 #2
0
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
예제 #3
0
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
예제 #4
0
    def parseFile(self, s):
        fichierBeerXML = s
        try:
            self.arbre = ET.parse(fichierBeerXML)
            presentation = self.arbre.find('.//RECIPE')  # noqa
            fermentables = self.arbre.findall('.//FERMENTABLE')
            hops = self.arbre.findall('.//HOP')
            levures = self.arbre.findall('.//YEAST')
            misc = self.arbre.findall('.//MISC')

            for element in hops:
                ImportBase.addHop(Hop.parse(element))
            for element in fermentables:
                ImportBase.addFermentable(Fermentable.parse(element))
            for element in misc:
                ImportBase.addMisc(Misc.parse(element))
            for element in levures:
                ImportBase.addYeast(Yeast.parse(element))
        except:
            self.warningFile()

        self.hopsNum = len(hops)
        self.fermNum = len(fermentables)
        self.miscNum = len(misc)
        self.yeastNum = len(levures)

        self.info()
예제 #5
0
 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()
예제 #6
0
파일: base.py 프로젝트: j0ack/joliebulle
 def delHop(h):
     ImportBase().listeHops.remove(h)
     root = ImportBase().arbre.getroot()
     iterator = root.iter("HOP")
     item = None
     for elem in iterator:
         tempHop = Hop.parse(elem)
         if (h.name == tempHop.name and h.form == tempHop.form
                 and h.alpha == tempHop.alpha):
             item = elem
     if item is not None:
         root.remove(item)
         ImportBase.save(root)
예제 #7
0
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
예제 #8
0
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
예제 #9
0
파일: base.py 프로젝트: j0ack/joliebulle
    def __init__(self):
        logger.debug("Import %s", database_file)
        fichierBeerXML = database_file
        self.arbre = ET.parse(fichierBeerXML)

        presentation = self.arbre.find('.//RECIPE')
        fermentables = self.arbre.findall('.//FERMENTABLE')
        hops = self.arbre.findall('.//HOP')
        levures = self.arbre.findall('.//YEAST')
        misc = self.arbre.findall('.//MISC')

        self.listeFermentables = list()
        self.listeHops = list()
        self.listeYeasts = list()
        self.listeMiscs = list()

        # Ingredient fermentescibles
        for element in fermentables:
            self.listeFermentables.append(Fermentable.parse(element))
        self.listeFermentables = sorted(self.listeFermentables,
                                        key=attrgetter('name'))
        logger.debug("%s fermentables in database, using %s bytes in memory",
                     len(self.listeFermentables),
                     sys.getsizeof(self.listeFermentables))

        # Houblons
        for element in hops:
            self.listeHops.append(Hop.parse(element))
        self.listeHops = sorted(self.listeHops, key=attrgetter('name'))
        logger.debug("%s hops in database, using %s bytes in memory",
                     len(self.listeHops), sys.getsizeof(self.listeHops))

        # Levures
        for element in levures:
            self.listeYeasts.append(Yeast.parse(element))
        self.listeYeasts = sorted(self.listeYeasts, key=attrgetter('name'))
        logger.debug("%s yeasts in database, using %s bytes in memory",
                     len(self.listeYeasts), sys.getsizeof(self.listeYeasts))

        # Ingredients divers
        for element in misc:
            self.listeMiscs.append(Misc.parse(element))
        self.listeMiscs = sorted(self.listeMiscs, key=attrgetter('name'))
        logger.debug("%s miscs in database, using %s bytes in memory",
                     len(self.listeMiscs), sys.getsizeof(self.listeMiscs))

        logger.debug("Import %s terminé", database_file)

        # Import Mash file
        logger.debug("Import %s", mash_file)
        arbre = ET.parse(mash_file)

        mash = arbre.findall('.//MASH')
        self.listeMashes = list()

        for element in mash:
            self.listeMashes.append(Mash.parse(element))
        logger.debug("%s mash in database, using %s bytes in memory",
                     len(self.listeMashes), sys.getsizeof(self.listeMashes))

        logger.debug("Import %s terminé", mash_file)
예제 #10
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