def ConvertFilesCustom(self, map_name, direction): self.MappingFile = map_name p = Payyans(self.InputFile, self.OutputFile, self.MappingFile) if direction == "a2u": return p.ascii2unicode() elif direction == "u2a": return p.unicode2ascii()
def ConvertFiles(self, map_name, direction): self.MappingFile = sys.prefix + "/share/payyans/maps/" + map_name p = Payyans(self.InputFile, self.OutputFile, self.MappingFile) if direction == "a2u": return p.ascii2unicode() elif direction == "u2a": return p.unicode2ascii()
def __convert_file(self, event): """ പയ്യനെ വിളിക്ക്യാ, ഇനി നോം ഗ്യാലറിയിലിരുന്ന് കളി കാണട്ടെ. """ # self.AsciiFile = self.ascii_btn.get_filename() self.MappingFile = self.mapping_btn.get_filename() # self.UnicodeFile = self.unicode_btn.get_filename() if self.a2u_radio.get_active() == True: direction = "a2u" from_file = self.AsciiFile to_file = self.UnicodeFile else: direction = "u2a" from_file = self.UnicodeFile to_file = self.AsciiFile if from_file == None or self.MappingFile == None: dlg = gtk.MessageDialog( self.get_toplevel(), gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, _("Please select both Input file and Mapping file"), ) dlg.run() dlg.destroy() return if to_file == None: (inp_file, inp_ext) = os.path.splitext(from_file) if direction == "a2u": self.UnicodeFile = inp_file + "-unicode" + ".txt" else: self.AsciiFile = inp_file + "-ascii" + ".txt" # ഓഹ്, പയ്യന്! നീ വ്യാഘ്രമാകുന്നു. if direction == "a2u": payyan = Payyans(self.AsciiFile, self.UnicodeFile, self.MappingFile) status = payyan.ascii2unicode() else: payyan = Payyans(self.UnicodeFile, self.AsciiFile, self.MappingFile) status = payyan.unicode2ascii() print status if status == 0: if direction == "a2u": msg = _("Coversion Done - Unicode file : ") + self.UnicodeFile else: msg = _("Conversion Done - ASCII file : ") + self.AsciiFile if status == 1: msg = _("Could not find the pdftotext utility. Exiting...") if status == 2: msg = _("Syntax Error in Mapping file. Exiting...") # കത്തിച്ചു കഴിഞ്ഞു. dlg = gtk.MessageDialog(self.get_toplevel(), gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, msg) dlg.run() dlg.destroy() return
def covertDocWithPayyans(self, inFile, mapFile, outFile, direction): ''' Call Payyans to do the actual conversion ''' # @direction : a2u/u2a for ASCII-to-Unicode and vice versa self.convertDocToText(inFile) p=Payyans(self.textfile, os.path.abspath(outFile), os.path.abspath(mapFile)) if not p: raise SystemExit("Couldn't create Payyan instance") if direction == "a2u": p.ascii2unicode() else: p.unicode2ascii()
def __convert_file(self, event): ''' പയ്യനെ വിളിക്ക്യാ, ഇനി നോം ഗ്യാലറിയിലിരുന്ന് കളി കാണട്ടെ. ''' #self.AsciiFile = self.ascii_btn.get_filename() self.MappingFile = self.mapping_btn.get_filename() #self.UnicodeFile = self.unicode_btn.get_filename() if self.a2u_radio.get_active() == True: direction = "a2u" from_file = self.AsciiFile to_file = self.UnicodeFile else: direction = "u2a" from_file = self.UnicodeFile to_file = self.AsciiFile if (from_file == None or self.MappingFile == None): dlg = gtk.MessageDialog( self.get_toplevel(), gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, _("Please select both Input file and Mapping file")) dlg.run() dlg.destroy() return if to_file == None: (inp_file, inp_ext) = os.path.splitext(from_file) if direction == "a2u": self.UnicodeFile = inp_file + "-unicode" + ".txt" else: self.AsciiFile = inp_file + "-ascii" + ".txt" # ഓഹ്, പയ്യന്! നീ വ്യാഘ്രമാകുന്നു. if direction == "a2u": payyan = Payyans(self.AsciiFile, self.UnicodeFile, self.MappingFile) status = payyan.ascii2unicode() else: payyan = Payyans(self.UnicodeFile, self.AsciiFile, self.MappingFile) status = payyan.unicode2ascii() print status if status == 0: if direction == "a2u": msg = _("Coversion Done - Unicode file : ") + self.UnicodeFile else: msg = _("Conversion Done - ASCII file : ") + self.AsciiFile if status == 1: msg = _("Could not find the pdftotext utility. Exiting...") if status == 2: msg = _("Syntax Error in Mapping file. Exiting...") # കത്തിച്ചു കഴിഞ്ഞു. dlg = gtk.MessageDialog(self.get_toplevel(), gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, msg) dlg.run() dlg.destroy() return
def covertDocWithPayyans(self, inFile, mapFile, outFile, direction): ''' Call Payyans to do the actual conversion ''' # @direction : a2u/u2a for ASCII-to-Unicode and vice versa self.convertDocToText(inFile) p = Payyans(self.textfile, os.path.abspath(outFile), os.path.abspath(mapFile)) if not p: raise SystemExit("Couldn't create Payyan instance") if direction == "a2u": p.ascii2unicode() else: p.unicode2ascii()
def payyans_ascii2unicode(text, font): P = Payyans() return P.ASCII2Unicode(text, font)
def payyans_unicode2ascii(text, font): P = Payyans() return P.Unicode2ASCII(text, font)