File: text_replace.py

package info (click to toggle)
inkscape 0.47.0-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 122,072 kB
  • ctags: 46,938
  • sloc: cpp: 349,791; ansic: 31,306; python: 14,868; xml: 6,613; sh: 5,041; makefile: 1,773; perl: 1,486; asm: 675; ruby: 148
file content (16 lines) | stat: -rw-r--r-- 658 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import chardataeffect, inkex, string

class C(chardataeffect.CharDataEffect):
  def __init__(self):
    chardataeffect.CharDataEffect.__init__(self)
    self.OptionParser.add_option("-f", "--from_text", action="store", type="string", dest="from_text", default="", help="Replace")
    self.OptionParser.add_option("-t", "--to_text", action="store", type="string", dest="to_text", default="", help="by")

  def process_chardata(self,text, line, par):
    fr = self.options.from_text.strip('"').replace('\$','$')
    to = self.options.to_text.strip('"').replace('\$','$')

    return (text.replace(unicode(fr,"utf-8"), unicode(to,"utf-8")))

c = C()
c.affect()