Code

implemented proper error checking
[inkscape.git] / share / extensions / text_replace.py
1 #!/usr/bin/env python
2 import chardataeffect, inkex, string
4 class C(chardataeffect.CharDataEffect):
5   def __init__(self):
6     chardataeffect.CharDataEffect.__init__(self)
7     self.OptionParser.add_option("-f", "--from_text", action="store", type="string", dest="from_text", default="", help="Replace")
8     self.OptionParser.add_option("-t", "--to_text", action="store", type="string", dest="to_text", default="", help="by")
10   def process_chardata(self,text, line, par):
11     fr = self.options.from_text.strip('"').replace('\$','$')
12     to = self.options.to_text.strip('"').replace('\$','$')
14     return (text.replace(unicode(fr,"utf-8"), unicode(to,"utf-8")))
16 c = C()
17 c.affect()