def transferVIPOtranslation(self, callback=None):

        vi_po_doc = Document(self.vi_po_path)
        vi_po_doc.loadText()
        vi_po_doc.sortDocumentInMSGID()
        #print(vi_po_doc)
        #return

        getter = POBasic(self.po_dir, False)
        po_dir_list = getter.getSortedPOFileList()

        for (index, po_file_path) in enumerate(po_dir_list):
            if (len(po_file_path) <= 0):
                continue

            #print("{}\n{}".format(po_file_path, len(po_file_path) * "="))
            po_doc = Document(po_file_path)
            po_doc.loadText()

            if ((callback != None)
                    and isinstance(callback, TwoDocumentAction)):
                callback.setArgs(vi_po_doc, po_doc)
                callback.run()

            if (po_doc.isDirty()):
                print("SAVING DOCUMENT: {}".format(po_doc.path))
Beispiel #2
0
    def processingFilePair(self):

        from_po_doc = to_po_doc = None

        has_from = (self.from_vi_po != None)
        has_to = (self.to_vi_po != None)

        #print("processingFilePair: has_from={}, has_to={}".format(has_from, has_to))

        if (has_from):
            from_po_doc = Document(self.from_vi_po)
            from_po_doc.loadPOText()
            #print(from_po_doc)

        if (has_to):
            to_po_doc = Document(self.to_vi_po)
            to_po_doc.loadPOText()
            #print(to_po_doc)

        if ((self.docEventHandler != None)
                and isinstance(self.docEventHandler, TwoDocumentAction)):
            self.docEventHandler.setArgs(from_po_doc, to_po_doc)
            self.docEventHandler.run()

        #if (po_doc.isDirty()): print(po_doc)
        if (has_to and to_po_doc.isDirty()):
            if (self.out_vi_po == None):
                print("Saving changes to:{}".format(to_po_doc.path))
                to_po_doc.saveText(out_path=None)
            else:
                print("Saving changes to otherfile:{}".format(self.out_vi_po))
                to_po_doc.saveText(out_path=self.out_vi_po)
Beispiel #3
0
    def ProcessingFile(self):

        po_doc = Document(self.vi_po_path)
        po_doc.loadText()

        if ((self.docEventHandler != None)
                and isinstance(self.docEventHandler, DocumentAction)):
            self.docEventHandler.setArgs(po_doc)
            self.docEventHandler.run()

        #if (po_doc.isDirty()): print(po_doc)
        if (po_doc.isDirty()): po_doc.saveText()
    def compareDir(self):

        getter = POBasic(self.left_dir, False)
        left_dir_list = getter.getSortedPOFileListRelative()

        #right_dir_list = self.getSortedPOFileList(self.right_dir, ".po")
        #print("self.left_dir: {} left_dir_list: {}".format(self.left_dir, left_dir_list))
        for (index, common_name) in enumerate(left_dir_list):
            #print("common_name: {} index: {}".format(common_name, index))

            #is_debug = (common_name.find("outliner") >= 0)
            #if (is_debug):
            #    print("common_name: {}".format(common_name))
            #exit(0)

            left_file_name = self.left_dir + common_name
            right_file_name = self.right_dir + common_name

            po_left = Document(left_file_name)
            po_left.loadText()
            is_there = os.path.isfile(right_file_name)

            # print("left_file_name: {} is_there: {}".format(left_file_name, is_there))
            # print("right_file_name: {} is_there: {}".format(right_file_name, is_there))
            # exit(1)
            if (is_there):
                po_right = Document(right_file_name)
                po_right.loadText()

                left_text = po_left.getAllMSGID()
                right_text = po_right.getAllMSGID()
                md5left = self.getMD5(left_text)
                md5right = self.getMD5(right_text)

                #if (is_debug):
                #print("\n\n--------------\nleft_text:[{}]\n***********\nright_text:[{}], is_equal:{}\n----------------------------\n\n".format(po_left, po_right, md5left == md5right))
                #exit(0)

                is_diff = (md5left != md5right)
                if (is_diff):
                    print(
                        "file: {}\nleft: {}\nright: {}\nis_diff: {}\nis_fix: {}"
                        .format(common_name, self.left_dir, self.right_dir,
                                is_diff, self.is_fix))
                    if (self.is_fix):
                        self.transferText(po_left, po_right)
                        if (po_right.isDirty()):
                            print("Saving: {}".format(po_right.path))
                            #po_right.saveText()
                #print(line_sep)
            else:
                print("DOESN'T EXIST: {}".format(right_file_name))
    def ProcessingSingleDoc(self, po_doc: Document):

        if ((self.docEventHandler != None)
                and isinstance(self.docEventHandler, DocumentAction)):
            self.docEventHandler.setArgs(po_doc)
            self.docEventHandler.run()

        if (po_doc.isDirty()):
            if (self.out_vi_po == None):
                print("Saving changes to:{}".format(po_doc.path))
                po_doc.saveText(out_path=None)
            else:
                print("Saving changes to otherfile:{}".format(self.out_vi_po))
                po_doc.saveText(out_path=self.out_vi_po)
Beispiel #6
0
    def loadPOFilesForProcessing(self):

        getter = POBasic(self.po_dir, False)
        po_dir_list = getter.getSortedPOFileList()

        for (index, po_file_path) in enumerate(po_dir_list):
            if (len(po_file_path) <= 0):
                continue

            #print("{}\n{}".format(po_file_path, len(po_file_path) * "="))
            po_doc = Document(po_file_path)
            po_doc.loadText()

            if ((self.docEventHandler != None)
                    and isinstance(self.docEventHandler, DocumentAction)):
                self.docEventHandler.setArgs(po_doc)
                self.docEventHandler.run()

            #if (po_doc.isDirty()): print(po_doc)
            #if (po_doc.isDirty()): print("Saving: {}".format(po_doc.path))
            if (po_doc.isDirty()):
                po_doc.saveText()
                po_doc.msg("")
                key = input("Press any key to continue, Ctrl+C to break")