def open_file(self): directory = os.path.expanduser("~") filename = QFileDialog.getOpenFileName(self, self.tr("Abrir Archivo"), directory, settings.DBFILE, QFileDialog.DontUseNativeDialog) if not filename: return ext = file_manager.get_extension(filename) if ext == '.pqf': # Query file self.new_query(filename) else: self.create_data_base(filename)
def open_file(self): if self.__last_open_folder is None: directory = os.path.expanduser("~") else: directory = self.__last_open_folder filename = QFileDialog.getOpenFileName(self, self.tr("Abrir Archivo"), directory, settings.DBFILE, QFileDialog.DontUseNativeDialog) if not filename: return # Save folder self.__last_open_folder = file_manager.get_path(filename) ext = file_manager.get_extension(filename) if ext == '.pqf': # Query file self.new_query(filename) elif ext == '.rdb': self.load_rdb_database(file_manager.read_rdb_file(filename)) else: self.create_data_base(filename)
def test_get_extension(self): filename = "/home/gabo/database.pdb" expected = ".pdb" extension = file_manager.get_extension(filename) self.assertEqual(expected, extension)
def test_get_extension(filename, expected): assert file_manager.get_extension(filename) == expected