def lrelease(self, ts_input_file: str, qm_output_file: str, stripped: bool = True) -> None: """ Convert the .ts file to .qm. @param tsImputFile. Source .ts file name. @param qmOutputFile. Destination .qm file name. @param stripped. Not used. """ from pineboolib import application verbose = False metTranslations = False f = Qt.QFile(ts_input_file) if not f.open(QtCore.QIODevice.ReadOnly): self.logger.warning("Cannot open file '%s'", ts_input_file) return t = Qt.QTextStream(f) full_text = t.readAll() f.close() if full_text.find("<!DOCTYPE TS>") >= 0: self.releaseTsFile(ts_input_file, verbose, stripped) else: if application.PROJECT.conn_manager is None: raise Exception("Project has no connection yet") key = application.PROJECT.conn_manager.managerModules().shaOfFile( ts_input_file) tagMap = full_text # TODO: hay que cargar todo el contenido del fichero en un diccionario for key, value in tagMap: toks = value.split(" ") for t in toks: if key == "TRANSLATIONS": metTranslations = True self.releaseTsFile(t, verbose, stripped) if not metTranslations: self.logger.warning( "Met no 'TRANSLATIONS' entry in project file '%s'", ts_input_file)
def _showFile(self, file_name): """ Display a information sub-window listing the content of specified file. Arguments: file_name (str): Path to the file. """ info_file = Q.QFile(file_name) if not info_file.open(Q.QFile.ReadOnly): return stream = Q.QTextStream(info_file) info = stream.readAll() info_file.close() self.info_te.setText(info) self.layout().setCurrentIndex(1)
def loadQImageFix(path): try: f = Qt.QFile(path) if not f.open(Qt.QFile.ReadOnly): print("loadQImageFix(): could not open file:", path) return None data = f.readAll() f.close() del f image = Qt.QPixmap() image.loadFromData(data) data.clear() del data return image except Exception as e: print("Exception:", e.__class__.__name__, e) traceback.print_exc() return None