Mercurial > hg > config
annotate python/accentuate.py @ 127:8ac0ee508da7
another channel
| author | Jeff Hammel <jhammel@mozilla.com> |
|---|---|
| date | Wed, 09 Mar 2011 15:21:11 -0800 |
| parents | 6d2e986c0dae |
| children | a612a16f11a7 |
| rev | line source |
|---|---|
|
125
a51df2382390
new program that does silly things
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
|
a51df2382390
new program that does silly things
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
|
a51df2382390
new program that does silly things
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
3 |
|
a51df2382390
new program that does silly things
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
4 import random |
|
a51df2382390
new program that does silly things
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
5 |
| 126 | 6 mapping = {'a': ['Ȁ', 'ȁ', 'à'], |
|
125
a51df2382390
new program that does silly things
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
7 'c': ['ç'], |
|
a51df2382390
new program that does silly things
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
8 'e': ['ȅ'], |
|
a51df2382390
new program that does silly things
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
9 'n': ['И'], |
|
a51df2382390
new program that does silly things
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
10 'o': ['ổ', 'ȍ'], |
|
a51df2382390
new program that does silly things
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
11 't': ['Ṱ'], |
|
a51df2382390
new program that does silly things
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
12 } |
|
a51df2382390
new program that does silly things
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
13 |
|
a51df2382390
new program that does silly things
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
14 if __name__ == '__main__': |
|
a51df2382390
new program that does silly things
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
15 import sys |
|
a51df2382390
new program that does silly things
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
16 arg = ' '.join(sys.argv[1:]) |
|
a51df2382390
new program that does silly things
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
17 retval = [] |
|
a51df2382390
new program that does silly things
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
18 for letter in arg: |
|
a51df2382390
new program that does silly things
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
19 if letter.lower() in mapping: |
|
a51df2382390
new program that does silly things
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
20 retval.append(random.sample(mapping[letter.lower()], 1)[0]) |
|
a51df2382390
new program that does silly things
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
21 else: |
|
a51df2382390
new program that does silly things
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
22 retval.append(letter) |
|
a51df2382390
new program that does silly things
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
23 print ''.join(retval) |
