Mercurial > pyarq-presupuestos
diff Gtk/importFiebdc.py @ 5:6502bfdaa84d
update import durus database
author | Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es> |
---|---|
date | Sat, 06 Nov 2010 21:30:33 +0100 |
parents | 4e976a99efb9 |
children | 2fc6b47dbe70 |
line wrap: on
line diff
--- a/Gtk/importFiebdc.py Sun Oct 31 23:12:06 2010 +0100 +++ b/Gtk/importFiebdc.py Sat Nov 06 21:30:33 2010 +0100 @@ -52,18 +52,15 @@ "__readFileMethod": Method to read the selected file "__budget": Budget object "__filename": "file" - "__filetype": "budget" or "database" + "__filetype": "budget" ,"database" or "durus" "__cancelMethod": Method to cancel the read method "__file": The selected file "__window": The selection file window Methods: __init__(self, mainWindow, readFileMethod, budget arg_List, cancelMethod) - destroy(self, widget) - main(self) _launchProgressWindow(self, _file) - _openFile(self, w) - _openFile2(Self, filename) + _openFile(self, filename) """ def __init__(self, mainWindow, readFileMethod, budget, filename, @@ -76,7 +73,7 @@ budget: base.Budget object filename: "file" cancelMethod: Method to cancel the read method - fileytpe: "budget" or "database" + fileytpe: "budget", "database" or "durus". Sets the init atributes, creates the file selection window Connects the events: * clicked ok button: _openFile @@ -96,7 +93,11 @@ buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN,gtk.RESPONSE_OK)) self.__window.set_default_response(gtk.RESPONSE_OK) - self.__window.set_filename(globals.getHomePath("BUDGET")) + if self.__filetype == "budget" or self.__filetype == "database": + self.__window.set_current_folder(globals.getHomePath("BUDGET")) + else: # "durus" + self.__window.set_current_folder( + globals.getHomePath("DURUS-DATABASE")) if self.__window.run() == gtk.RESPONSE_OK: self._openFile(self.__window.get_filename()) self.__window.destroy() @@ -107,7 +108,6 @@ Launch the progress window """ self.__filename = file - _emptyPage = gui.EmptyPage(self.__mainWindow, self.__readFileMethod, self.__budget, self.__filename, self.__cancelMethod, self.__filetype) @@ -116,14 +116,6 @@ self.__mainWindow.getPageList().append(_emptyPage) _emptyPage.run() - def _launchProgressTab(self, file): - """def _launchProgressTab(self, file) - - Launch the progress window - """ - self.__filename = file - print "abriendo fichero", self.__filename - def _openFile(self, filename): """def _openFile(self, filename) @@ -140,14 +132,15 @@ self.__file = _file _filename = os.path.basename(self.__file) _filename_ext = _filename.split(".")[-1] - if _filename_ext != "bc3" and _filename_ext != "BC3": + if (self.__filetype == "budget" or self.__filetype == "database") and \ + _filename_ext != "bc3" and _filename_ext != "BC3": print _("The file must have 'bc3' extension") + elif self.__filetype == "durus" and _filename_ext != "durus": + print _("The file must have 'durus' extension") else: self.__window.destroy() - if self.__file: - # TODO: the file exits? is it not binary?, can it be readed? - self._launchProgressWindow(self.__file) - + # TODO: the file exits? is it not binary?, can it be readed? + self._launchProgressWindow(self.__file) class ProgressWindow(object): @@ -380,13 +373,13 @@ +--threading.Thread +-- importFiebdc.Thread Atributes: - "__page": The page instanca that launch the thread + "__page": The page instance that launch the thread "__mainWindow": gui.MainWindow instance "__readFileMethod": Method to read the selected file "__budget "__filename": "file" "__cancelMethod": Method to cancel the read method - "__filetype": "budget" or "database" + "__filetype": "budget", "database" or "durus" "__cancel": Boolean value, True: the thread is stoped Methods: __init__(self, page, mainWindow, @@ -407,7 +400,7 @@ budget: base.Budget object filename: "file" cancelMethod: Method to cancel the read method - feletype: "budget" or "basedate" + feletype: "budget", "database" or "durus" Sets the instance atributes. """ super(Thread, self).__init__() @@ -425,16 +418,15 @@ """ - _result = self.__readFileMethod(self.__budget, self.__filename, + _budget = self.__readFileMethod(self.__budget, self.__filename, self.__page) - if _result is None: + if _budget is None: self.__page.threadCanceled() else: _mainWindow = self.__mainWindow - _mainWindow._addBudget(_result) - self.__page.closeWindow() - - if self.__filetype == "basedate": + _mainWindow._addBudget(_budget) + self.__page.threadFinishedSignal(_budget) + if self.__filetype == "database": self.saveDurusDatabase() self.clear() @@ -475,8 +467,4 @@ del self.__budget del self.__filename del self.__cancelMethod - del self.__cancel - - - - + del self.__cancel \ No newline at end of file