def open(self, path: str): _translate = QCoreApplication.translate self.file = QFile(path) if self.file.exists(): file_path = self.file.fileName() # type: str open_gnl_file_result = self.open_gnl_file(file_path, self.tmp_directory) logger.debug(open_gnl_file_result) logger.debug(isinstance(open_gnl_file_result, ZippedDocument)) if isinstance(open_gnl_file_result, ZippedDocument): zip_file = open_gnl_file_result # type: ZipFile # noinspection PyTypeChecker,PyCallByClass self.database = QSqlDatabase.cloneDatabase( zip_file.database, ':memory:' ) self.init_database() zip_file.close() self.document_created.emit() else: self.error_occurred.emit(open_gnl_file_result) else: self.file = None selected_file_does_not_exist = _translate( "DocumentService", "The selected file ({}) does not exist." ) self.error_occurred.emit( DocumentError( selected_file_does_not_exist.format( path ) ) )
def open(self, path: str): _translate = QCoreApplication.translate self.file = QFile(path) if self.file.exists(): file_path = self.file.fileName() # type: str open_gnl_file_result = self.open_gnl_file(file_path, self.tmp_directory) logger.debug(open_gnl_file_result) logger.debug(isinstance(open_gnl_file_result, ZippedDocument)) if isinstance(open_gnl_file_result, ZippedDocument): zip_file = open_gnl_file_result # type: ZipFile # noinspection PyTypeChecker,PyCallByClass self.database = QSqlDatabase.cloneDatabase( zip_file.database, ':memory:') self.init_database() zip_file.close() self.document_created.emit() else: self.error_occurred.emit(open_gnl_file_result) else: self.file = None selected_file_does_not_exist = _translate( "DocumentService", "The selected file ({}) does not exist.") self.error_occurred.emit( DocumentError(selected_file_does_not_exist.format(path)))
def clone_db(self, name): return QSqlDatabase.cloneDatabase(self.db, name)