21
by 314r
maj infos legales, finale 2.1 |
1 |
#!/usr/bin/python3.1
|
4
by 314r
pret pour le packaging |
2 |
#*coding: utf8 -*
|
3 |
||
4 |
||
5 |
||
316
by 314r
maj mentions de copyright, nettoyage |
6 |
#JolieBulle 2.8
|
7 |
#Copyright (C) 2010-2013 Pierre Tavares
|
|
4
by 314r
pret pour le packaging |
8 |
|
9 |
#This program is free software; you can redistribute it and/or
|
|
10 |
#modify it under the terms of the GNU General Public License
|
|
11 |
#as published by the Free Software Foundation; either version 3
|
|
12 |
#of the License, or (at your option) any later version.
|
|
13 |
||
14 |
#This program is distributed in the hope that it will be useful,
|
|
15 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17 |
#GNU General Public License for more details.
|
|
18 |
||
19 |
#You should have received a copy of the GNU General Public License
|
|
20 |
#along with this program; if not, write to the Free Software
|
|
21 |
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
22 |
||
23 |
||
24 |
||
25 |
||
26 |
import PyQt4 |
|
27 |
import sys |
|
28 |
from PyQt4 import QtGui |
|
29 |
from PyQt4 import QtCore |
|
30 |
import xml.etree.ElementTree as ET |
|
33
by 314r
deplacement de database.xml dans ./config/joliebulle |
31 |
from globals import * |
4
by 314r
pret pour le packaging |
32 |
|
33 |
||
34 |
||
35 |
class ImportBase : |
|
36 |
||
37 |
||
38 |
def importBeerXML(self) : |
|
33
by 314r
deplacement de database.xml dans ./config/joliebulle |
39 |
fichierBeerXML = database_file |
4
by 314r
pret pour le packaging |
40 |
arbre = ET.parse(fichierBeerXML) |
41 |
||
42 |
presentation=arbre.find('.//RECIPE') |
|
43 |
fermentables=arbre.findall('.//FERMENTABLE') |
|
44 |
hops = arbre.findall('.//HOP') |
|
45 |
levures = arbre.findall('.//YEAST') |
|
46 |
misc = arbre.findall('.//MISC') |
|
47 |
||
48 |
||
49 |
||
50 |
#Ingredient fermentescibles
|
|
51 |
self.nbreFer = len(fermentables) |
|
52 |
self.liste_ingr = list() |
|
53 |
self.liste_fAmount = list() |
|
54 |
self.liste_fType = list() |
|
55 |
self.liste_fYield = list() |
|
56 |
self.liste_fMashed = list() |
|
57 |
self.liste_color = list() |
|
58 |
self.fMashed = '' |
|
59 |
||
60 |
||
61 |
i = 0 |
|
62 |
while i < self.nbreFer : |
|
63 |
||
64 |
i=i+1 |
|
65 |
for nom in fermentables[i-1] : |
|
66 |
if nom.tag == 'NAME' : |
|
67 |
self.fNom = nom.text |
|
68 |
self.liste_ingr.append(self.fNom) |
|
69 |
||
70 |
if nom.tag =='AMOUNT' : |
|
71 |
self.fAmount = 1000*(float(nom.text)) |
|
72 |
self.liste_fAmount.append(self.fAmount) |
|
73 |
||
74 |
if nom.tag =='TYPE' : |
|
75 |
self.fType = nom.text |
|
76 |
self.liste_fType.append(self.fType) |
|
77 |
||
78 |
if nom.tag == 'YIELD' : |
|
79 |
self.fYield = float(nom.text) |
|
80 |
self.liste_fYield.append(self.fYield) |
|
81 |
||
82 |
if nom.tag == 'RECOMMEND_MASH' : |
|
83 |
self.fMashed = nom.text |
|
84 |
self.liste_fMashed.append(self.fMashed) |
|
85 |
||
86 |
#ATTENTION ! le format BeerXML utilise des unités SRM !
|
|
87 |
#srm*1.97 =ebc
|
|
88 |
if nom.tag == 'COLOR' : |
|
89 |
self.color = float(nom.text)*1.97 |
|
90 |
self.liste_color.append(self.color) |
|
91 |
||
92 |
||
93 |
||
94 |
||
95 |
#Houblons
|
|
96 |
||
97 |
self.nbreHops = len(hops) |
|
98 |
self.liste_houblons = list() |
|
99 |
self.liste_hAmount = list() |
|
100 |
self.liste_hForm = list() |
|
101 |
self.liste_hTime = list() |
|
102 |
self.liste_hAlpha = list() |
|
103 |
||
104 |
||
105 |
||
106 |
h = 0 |
|
107 |
while h < self.nbreHops : |
|
108 |
h = h+1 |
|
109 |
for nom in hops [h-1] : |
|
110 |
if nom.tag == 'NAME' : |
|
111 |
self.hNom = nom.text |
|
112 |
self.liste_houblons.append(self.hNom) |
|
113 |
||
114 |
if nom.tag =='AMOUNT' : |
|
115 |
self.hAmount = 1000*(float(nom.text)) |
|
116 |
self.liste_hAmount.append(self.hAmount) |
|
117 |
||
118 |
if nom.tag =='FORM' : |
|
119 |
self.hForm = nom.text |
|
120 |
self.liste_hForm.append(self.hForm) |
|
121 |
||
122 |
if nom.tag =='TIME' : |
|
123 |
self.hTime = float(nom.text) |
|
124 |
self.liste_hTime.append(self.hTime) |
|
125 |
||
126 |
||
127 |
if nom.tag =='ALPHA' : |
|
128 |
self.hAlpha = float(nom.text) |
|
129 |
self.liste_hAlpha.append(self.hAlpha) |
|
130 |
||
131 |
||
132 |
||
133 |
||
134 |
||
135 |
#Levure
|
|
136 |
self.nbreLevures = len(levures) |
|
137 |
self.liste_levures = list() |
|
138 |
self.liste_lForm = list() |
|
139 |
self.liste_lLabo = list() |
|
140 |
self.liste_lProdid = list() |
|
141 |
self.liste_levuresDetail = list() |
|
142 |
self.liste_levureAtten = list () |
|
143 |
self.lNom = "" |
|
144 |
self.lLabo ="" |
|
145 |
self.lProd ="" |
|
146 |
self.lForm = "" |
|
147 |
self.lAtten="" |
|
148 |
||
149 |
l = 0 |
|
150 |
while l < self.nbreLevures : |
|
151 |
l = l+1 |
|
152 |
for nom in levures [l-1] : |
|
153 |
if nom.tag == 'NAME' : |
|
154 |
self.lNom = str(nom.text) |
|
155 |
self.liste_levures.append(self.lNom) |
|
156 |
||
157 |
if nom.tag == 'FORM' : |
|
158 |
self.lForm = str(nom.text) |
|
159 |
self.liste_lForm.append(self.lForm) |
|
160 |
||
161 |
if nom.tag == 'LABORATORY' : |
|
162 |
self.lLabo = str(nom.text) |
|
163 |
self.liste_lLabo.append(self.lLabo) |
|
164 |
||
165 |
if nom.tag == 'PRODUCT_ID' : |
|
166 |
self.lProd = str(nom.text) |
|
167 |
self.liste_lProdid.append(self.lProd) |
|
168 |
||
169 |
if nom.tag == 'ATTENUATION' : |
|
170 |
self.lAtten = float(nom.text) |
|
171 |
self.liste_levureAtten.append(self.lAtten) |
|
172 |
||
173 |
||
174 |
||
5
by 314r
changement selection levures |
175 |
self.liste_levuresDetail.append (self.lNom+ ' ' + self.lLabo +' ' + self.lProd) |
4
by 314r
pret pour le packaging |
176 |
|
177 |
||
178 |
||
179 |
||
180 |
||
181 |
||
182 |
#Ingredients divers
|
|
183 |
self.nbreDivers = len(misc) |
|
184 |
self.liste_divers = list () |
|
185 |
self.liste_dAmount = list () |
|
186 |
self.liste_dType = list () |
|
187 |
self.dNom = '' |
|
188 |
self.dAmount = 0 |
|
189 |
self.dType = '' |
|
190 |
||
191 |
||
192 |
m = 0 |
|
193 |
while m < self.nbreDivers : |
|
194 |
m = m+1 |
|
195 |
for nom in misc [m-1] : |
|
196 |
if nom.tag == 'NAME' : |
|
197 |
self.dNom = nom.text |
|
198 |
self.liste_divers.append(self.dNom) |
|
199 |
||
200 |
if nom.tag == 'AMOUNT' : |
|
201 |
self.dAmount = float(nom.text)*1000 |
|
202 |
self.liste_dAmount.append(self.dAmount) |
|
203 |
||
204 |
if nom.tag == 'TYPE' : |
|
205 |
self.dType = nom.text |
|
206 |
self.liste_dType.append(self.dType) |