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