1
2
3
4 """
5 Manage all the Pycalcar Software
6
7 G{importgraph}
8 """
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 import sys
29
30 import ihm_pycalcar
31 import sqlite_pycalcar
32 import money_op_pycalcar
33 import path_mkr
34
35
37 """
38 Class which manage the entire Pycalcar software
39
40 G{classtree}
41 """
42
43
44
45
47 self.path_base = path_mkr.cxf_get_path()
48 self.operand = self.p_init_operand()
49 self.bdd, list_toolbar, list_calc, list_conv, list_param, list_about, list_money, list_lang, list_rate, list_message, language = self.f_init_bdd()
50
51 interface = self.f_init_ihm(list_toolbar, list_calc, list_conv, list_param, list_money, list_lang, list_rate, list_about, list_message, language)
52
53 self.p_start_software(interface)
54
55
56
57
58
59
60
66
67
68
69
70
71
72
74
75 bdd = sqlite_pycalcar.SqlitePycalcar(self.path_base)
76 language = bdd.f_config_get_language()
77 list_toolbar, list_calc, list_conv, list_param, list_about = bdd.f_read_menu_text(language)
78 list_money = bdd.f_read_money_name()
79 list_lang = bdd.f_read_lang()
80 list_rate = bdd.f_read_money_rate(list_money[0][0],list_money[0][1],list_money[0][2])
81 list_message = bdd.f_read_message(language)
82
83
84 return bdd, list_toolbar, list_calc, list_conv, list_param, list_about, list_money, list_lang, list_rate, list_message, language
85
86
87
88
89
90
91
92 - def f_init_ihm(self, list_toolbar, list_calc, list_conv, list_param, list_money, list_lang, list_rate, list_about, list_message, language):
93
94 interface = ihm_pycalcar.IhmPycalcar(self.f_operation_add,self.f_operation_sub,self.f_operation_mult,self.f_operation_div,\
95 list_toolbar, list_calc, list_conv, list_param, list_money,\
96 list_lang,list_rate,self.f_money_read_rates, self.f_cbox_conv, list_about, self.p_money_create,\
97 self.p_money_update, self.p_money_delete, self.p_rate_crupds, self.p_rate_delete, \
98 self.p_lang_change, self.f_conv_go, self.f_moneys_read_rate, self.f_rate_read, \
99 self.f_money_reloaded, list_message, self.path_base, language)
100
101 return interface
102
103
104
105
106
107
108
113
114
115
116
117
118
119
120 - def f_operation_add(self,unit10,unit11,unit12,unit13,unit14,unit15,unit16,unit17,unit18,unit19,\
121 unit20,unit21,unit22,unit23,unit24,unit25,unit26,unit27,unit28,unit29,
122 rate0,rate1,rate2,rate3,rate4,rate5,rate6,rate7,rate8):
123
124 result = self.operand.f_money_add(unit10,unit11,unit12,unit13,unit14,unit15,unit16,unit17,unit18,unit19,\
125 unit20,unit21,unit22,unit23,unit24,unit25,unit26,unit27,unit28,unit29,
126 rate0,rate1,rate2,rate3,rate4,rate5,rate6,rate7,rate8)
127 return result
128
129
130
131
132
133
134
135 - def f_operation_sub(self,unit10,unit11,unit12,unit13,unit14,unit15,unit16,unit17,unit18,unit19,\
136 unit20,unit21,unit22,unit23,unit24,unit25,unit26,unit27,unit28,unit29,
137 rate0,rate1,rate2,rate3,rate4,rate5,rate6,rate7,rate8):
138
139 result = self.operand.f_money_sub(unit10,unit11,unit12,unit13,unit14,unit15,unit16,unit17,unit18,unit19,\
140 unit20,unit21,unit22,unit23,unit24,unit25,unit26,unit27,unit28,unit29,
141 rate0,rate1,rate2,rate3,rate4,rate5,rate6,rate7,rate8)
142 return result
143
144
145
146
147
148
149
150 - def f_operation_mult(self,unit20,unit10,unit11,unit12,unit13,unit14,unit15,unit16,unit17,unit18,unit19,
151 rate0,rate1,rate2,rate3,rate4,rate5,rate6,rate7,rate8):
152
153 result = self.operand.f_money_mult(unit20,unit10,unit11,unit12,unit13,unit14,unit15,unit16,unit17,unit18,unit19,
154 rate0,rate1,rate2,rate3,rate4,rate5,rate6,rate7,rate8)
155 return result
156
157
158
159
160
161
162
163 - def f_operation_div(self,unit20,unit10,unit11,unit12,unit13,unit14,unit15,unit16,unit17,unit18,unit19,
164 rate0,rate1,rate2,rate3,rate4,rate5,rate6,rate7,rate8):
165
166 result, reste = self.operand.f_money_div(unit20,unit10,unit11,unit12,unit13,unit14,unit15,unit16,unit17,unit18,unit19,
167 rate0,rate1,rate2,rate3,rate4,rate5,rate6,rate7,rate8)
168 return result, reste
169
170
171
172
173
174
175
180
181
182
183
184
185
186
188
189 value = self.bdd.f_read_rate(name1,year1,nation1,name2,year2,nation2)
190 return value
191
192
193
194
195
196
197
198 - def p_money_create(self,name,year,nation,nb_unit,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,\
199 tx0,tx1,tx2,tx3,tx4,tx5,tx6,tx7,tx8):
200
201 self.bdd.p_ins_money(name,year,nation,nb_unit,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,\
202 tx0,tx1,tx2,tx3,tx4,tx5,tx6,tx7,tx8)
203
204
205
206
207
208
209
210 - def p_money_update(self,old_name,old_year,old_nation,name,year,nation, \
211 nb_unit,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9, \
212 tx0,tx1,tx2,tx3,tx4,tx5,tx6,tx7,tx8):
213
214 self.bdd.p_upd_money(old_name,old_year,old_nation,name,year,nation, \
215 nb_unit,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9, \
216 tx0,tx1,tx2,tx3,tx4,tx5,tx6,tx7,tx8)
217
218
219
220
221
222
223
227
228
229
230
231
232
233
235
236 list_money = self.bdd.f_read_money_name()
237 list_rate = self.bdd.f_read_money_rate(list_money[0][0],list_money[0][1],list_money[0][2])
238
239 return list_money, list_rate
240
241
242
243
244
245
246
247 - def f_rate_read(self,name1,year1,nation1,name2,year2,nation2):
248
249 rate = self.bdd.f_read_rate(name1,year1,nation1,name2,year2,nation2)
250
251 return rate
252
253
254
255
256
257
258
259 - def p_rate_crupds(self,name1,year1,nation1,name2,year2,nation2,rate):
260
261 test = self.f_rate_read(name1,year1,nation1,name2,year2,nation2)
262
263 if (test == 0):
264 self.bdd.p_ins_rate(name1,year1,nation1,name2,year2,nation2,rate)
265 else:
266 self.bdd.p_upd_rate(name1,year1,nation1,name2,year2,nation2,rate)
267
268
269 test = self.f_rate_read(name2,year2,nation2,name1,year1,nation1)
270
271 if (test == 0):
272 self.bdd.p_ins_rate(name2,year2,nation2,name1,year1,nation1,1/rate)
273 else:
274 self.bdd.p_upd_rate(name2,year2,nation2,name1,year1,nation1,1/rate)
275
276
277
278
279
280
281
282 - def p_rate_delete(self,name1,year1,nation1,name2,year2,nation2):
283
284
285 self.bdd.p_del_rate(name1,year1,nation1,name2,year2,nation2)
286
287
288
289
290
291
292
296
297
298
299
300
301
302
307
308
309
310
311
312
313
314 - def f_conv_go(self,unit10,unit11,unit12,unit13,unit14,unit15,unit16,unit17,unit18,unit19,\
315 rate10,rate11,rate12,rate13,rate14,rate15,rate16,rate17,rate18, \
316 rate20,rate21,rate22,rate23,rate24,rate25,rate26,rate27,rate28, \
317 rate_conv):
318
319 base1 = self.operand.f_convert_base(unit10,unit11,unit12,unit13,unit14,unit15,unit16,unit17,unit18,unit19,\
320 rate10,rate11,rate12,rate13,rate14,rate15,rate16,rate17,rate18)
321 base2 = base1 * rate_conv
322 base2 = int(base2 + 0.5)
323
324 return self.operand.f_convert_total(base2,rate20,rate21,rate22,rate23,rate24,rate25,rate26,rate27,rate28)
325
326
327
328
329
330
331
332 if __name__ == '__main__':
333 try:
334 software = PycalcarSoftware()
335 except:
336 print "error: ", sys.exc_info()
337 a = raw_input("Error")
338