예제 #1
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()
예제 #2
0
    def ajouter(self):
        m = Misc()
        m.name = self.ui.lineEditNom.text()

        if self.ui.comboBoxType.currentIndex() is 0:
            m.type = 'Spice'
        elif self.ui.comboBoxType.currentIndex() is 1:
            m.type = 'Fining'
        elif self.ui.comboBoxType.currentIndex() is 2:
            m.type = 'Water Agent'
        elif self.ui.comboBoxType.currentIndex() is 3:
            m.type = 'Herb'
        elif self.ui.comboBoxType.currentIndex() is 4:
            m.type = 'Flavor'
        elif self.ui.comboBoxType.currentIndex() is 5:
            m.type = 'Other'
        else:
            m.type = 'Spice'
        ImportBase.addMisc(m)
        self.setModel()