1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# Payyans Ascii to Unicode Convertor
# Copyright 2008 Santhosh Thottingal <santhosh.thottingal@gmail.com>, Nishan Naseer <nishan.naseer@gmail.com>, Manu S Madhav <manusmad@gmail.com>
# http://www.smc.org.in
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# If you find any bugs or have any suggestions email: santhosh.thottingal@gmail.com
# URL: http://www.smc.org.in
from payyans import Payyans
from optparse import OptionParser
import sys,os
def error_exit():
print '''
Payyans Malayalam Ascii <--> Unicode Converter Version 0.3
Please use --help or -h argument to see the options'''
sys.exit(1)
'''പയ്യന്റെ ക്ലാസ് ഉന്നതകുലമാകുന്നു. ച്ചാല് ആഢ്യന് തന്നെ. ഏ ക്ലാസ് പയ്യന്...!'''
class Payyan:
def __init__(self):
usage = "usage: %prog [options] arg"
parser = OptionParser(usage)
parser.add_option("-i", "--input-file", dest="input_filename", help="the input file in ascii format")
parser.add_option("-o", "--output-file", dest="output_filename", help="the output file name")
parser.add_option("-d", "--direction", dest="direction", help="'a2u': Ascii to Unicode, 'u2a': Unicode to Ascii")
parser.add_option("-m", "--mapping-file", dest="mapping_filename", help="the ascii to unicode mapping file name")
parser.add_option("-v", "--version", action="store_true", dest="version", help="print the version of this program")
(options, args) = parser.parse_args()
'''നീ ആരാകുന്നു?'''
if options.version :
'''ഞാന് പയ്യനാകുന്നു. പയ്യെ ജനനം. പൈത്തണ്കുലം. ഇങ്ങടു് കടിച്ചാല് അങ്ങടും കടിക്കും- അതു് ജന്മ സ്വഭാവം'''
print "Payyans Malayalam Ascii <--> Unicode Converter Version 0.3"
return
if (options.mapping_filename is None):
''' മാപ്പിങ്ങ് ഇല്ലാതെ നമുക്കെന്താഘാഷം'''
print "\tEnter mapping file"
error_exit()
if not os.path.exists(options.mapping_filename):
'''ഇല്ലാത്ത മാപ്പ് ഉണ്ടാക്കാന് പയ്യനാരാ, കൊളംബസോ? വേല കയ്യിലിലിരിക്കട്ടെ...'''
print "\tMap file " + options.mapping_filename + " not found"
error_exit()
if options.direction not in ['a2u','u2a']:
'''വഴി പറയൂ സഖാവേ'''
print "\tInvalid direction"
error_exit()
p=Payyans(options.input_filename ,options.output_filename, options.mapping_filename)
p.ascii2unicode()
if options.direction == 'a2u':
p.ascii2unicode()
else:
p.unicode2ascii()
if __name__ == "__main__":
'''ഒരു പയ്യന് അവതരിക്കുന്നു. '''
rule= Payyan()
|