Mercurial > pyarq-presupuestos
comparison Gtk/importFiebdc.py @ 16:60bc5117926c
no durus
author | Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es> |
---|---|
date | Fri, 19 Apr 2013 00:04:20 +0200 |
parents | fe9c55f86698 |
children | 7bd4ca56607d |
comparison
equal
deleted
inserted
replaced
15:2a13413dcc13 | 16:60bc5117926c |
---|---|
31 gobject.threads_init() | 31 gobject.threads_init() |
32 | 32 |
33 # pyArq-Presupuestos Modules | 33 # pyArq-Presupuestos Modules |
34 from Generic import utils | 34 from Generic import utils |
35 from Generic import globalVars | 35 from Generic import globalVars |
36 from Generic import durusdatabase | 36 #from Generic import durusdatabase |
37 import gui | 37 import gui |
38 | 38 |
39 class FileSelectionWindow(object): | 39 class FileSelectionWindow(object): |
40 """importFiebdc.FileSelectionWindow: | 40 """importFiebdc.FileSelectionWindow: |
41 | 41 |
91 self.__window = gtk.FileChooserDialog(title=_("Open File"), | 91 self.__window = gtk.FileChooserDialog(title=_("Open File"), |
92 action=gtk.FILE_CHOOSER_ACTION_OPEN, | 92 action=gtk.FILE_CHOOSER_ACTION_OPEN, |
93 buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL, | 93 buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL, |
94 gtk.STOCK_OPEN,gtk.RESPONSE_OK)) | 94 gtk.STOCK_OPEN,gtk.RESPONSE_OK)) |
95 self.__window.set_default_response(gtk.RESPONSE_OK) | 95 self.__window.set_default_response(gtk.RESPONSE_OK) |
96 if self.__filetype == "budget" or self.__filetype == "database": | 96 #if self.__filetype == "budget" or self.__filetype == "database": |
97 self.__window.set_current_folder(globalVars.getHomePath("BUDGET")) | 97 self.__window.set_current_folder(globalVars.getHomePath("BUDGET")) |
98 else: # "durus" | 98 #else: # "durus" |
99 self.__window.set_current_folder( | 99 # self.__window.set_current_folder( |
100 globalVars.getHomePath("DURUS-DATABASE")) | 100 # globalVars.getHomePath("DURUS-DATABASE")) |
101 if self.__window.run() == gtk.RESPONSE_OK: | 101 if self.__window.run() == gtk.RESPONSE_OK: |
102 self._openFile(self.__window.get_filename()) | 102 self._openFile(self.__window.get_filename()) |
103 self.__window.destroy() | 103 self.__window.destroy() |
104 | 104 |
105 def _launchProgressWindow(self, file): | 105 def _launchProgressWindow(self, file): |
131 _filename = os.path.basename(self.__file) | 131 _filename = os.path.basename(self.__file) |
132 _filename_ext = _filename.split(".")[-1] | 132 _filename_ext = _filename.split(".")[-1] |
133 if (self.__filetype == "budget" or self.__filetype == "database") and \ | 133 if (self.__filetype == "budget" or self.__filetype == "database") and \ |
134 _filename_ext != "bc3" and _filename_ext != "BC3": | 134 _filename_ext != "bc3" and _filename_ext != "BC3": |
135 print _("The file must have 'bc3' extension") | 135 print _("The file must have 'bc3' extension") |
136 elif self.__filetype == "durus" and _filename_ext != "durus": | 136 #elif self.__filetype == "durus" and _filename_ext != "durus": |
137 print _("The file must have 'durus' extension") | 137 # print _("The file must have 'durus' extension") |
138 else: | 138 else: |
139 self.__window.destroy() | 139 self.__window.destroy() |
140 # TODO: the file exits? is it not binary?, can it be readed? | 140 # TODO: the file exits? is it not binary?, can it be readed? |
141 self._launchProgressWindow(self.__file) | 141 self._launchProgressWindow(self.__file) |
142 | 142 |
421 if _budget is None: | 421 if _budget is None: |
422 self.__page.threadCanceled() | 422 self.__page.threadCanceled() |
423 else: | 423 else: |
424 _mainWindow = self.__mainWindow | 424 _mainWindow = self.__mainWindow |
425 self.__page.threadFinishedSignal(_budget) | 425 self.__page.threadFinishedSignal(_budget) |
426 if self.__filetype == "database": | 426 #if self.__filetype == "database": |
427 self.saveDurusDatabase() | 427 # self.saveDurusDatabase() |
428 self.clear() | 428 self.clear() |
429 | 429 |
430 def saveDurusDatabase(self): | 430 #def saveDurusDatabase(self): |
431 _path = globalVars.getHomePath("DURUS-DATABASE") | 431 # _path = globalVars.getHomePath("DURUS-DATABASE") |
432 _file_whit_path_bc3 = self.__budget.filename | 432 # _file_whit_path_bc3 = self.__budget.filename |
433 _filename_bc3 = _file_whit_path_bc3.split("/")[-1] | 433 # _filename_bc3 = _file_whit_path_bc3.split("/")[-1] |
434 _filename = _filename_bc3.split(".")[-2] | 434 # _filename = _filename_bc3.split(".")[-2] |
435 _file = _path + _filename + ".durus" | 435 # _file = _path + _filename + ".durus" |
436 print utils.mapping(_("Saving file: $1"), (_file,)) | 436 # print utils.mapping(_("Saving file: $1"), (_file,)) |
437 _time = time.time() | 437 # _time = time.time() |
438 _durus_file = durusdatabase.DurusFile(_file,True) | 438 # _durus_file = durusdatabase.DurusFile(_file,True) |
439 _durus_file.setBudget(self.__budget) | 439 # _durus_file.setBudget(self.__budget) |
440 _durus_file.close() | 440 # _durus_file.close() |
441 print utils.mapping(_("Saving time: $1 seconds"), | 441 # print utils.mapping(_("Saving time: $1 seconds"), |
442 (("%.2f" %(time.time()-_time) ),)) | 442 # (("%.2f" %(time.time()-_time) ),)) |
443 | 443 |
444 def cancel(self): | 444 def cancel(self): |
445 """cancel(self) | 445 """cancel(self) |
446 | 446 |
447 Sets the "__cancel" atribute to True and call "__cancelMethod" to stop | 447 Sets the "__cancel" atribute to True and call "__cancelMethod" to stop |