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 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()