File: text_randomcase.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 (27 lines) | stat: -rw-r--r-- 561 bytes parent folder | download
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
import chardataeffect, inkex, string

import random

class C(chardataeffect.CharDataEffect):

  def process_chardata(self,text, line, par):
    r = ""
    a = 1
    for i in range(len(text)):
      c = text[i]
      # bias the randomness towards inversion of the previous case:
      if a > 0:
        a = random.choice([-2,-1,1])
      else:
        a = random.choice([-1,1,2])
      if a > 0 and c.isalpha():
        r = r + c.upper()
      elif a < 0 and c.isalpha():
        r = r + c.lower()
      else:
        r = r + c

    return r

c = C()
c.affect()