예제 #1
0
    def removeComments(self):

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

        p = re.compile(Common.COMMENTED_LINE)
        update_count=0
        for(index, po_file_path) in enumerate(po_dir_list):
            if (len(po_file_path) <= 0):
                continue

            read_text = self.readFile(po_file_path)
            if (read_text == None):
                raise Exception("Unable to read text from file: {}".format(self.path))

            m = p.search(read_text)
            if (m == None):
                continue

            print("doc: {}".format(po_file_path))

            po_doc = Document(po_file_path)
            po_doc.loadText()
            po_doc.cleanupEmpties()

            print("po_doc: {}".format(po_doc.getTextWithIDFlat()))
            po_doc.saveText()
            update_count += 1
예제 #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)
예제 #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 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)
예제 #5
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")