munge.py

Mon, 05 Oct 2015 23:35:44 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Mon, 05 Oct 2015 23:35:44 +0300
changeset 161
6e7cb38f248d
parent 159
4c06dfae9beb
child 162
d24fe5e3e420
permissions
-rw-r--r--

Calculator now supports variables

158
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python3
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 # encoding: utf-8
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 '''
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 Provides the munge function.
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 '''
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 import string
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 mungechars = 'аɓᴄđеƒɡɦіјķɭṁɳорqŗѕƫᴜᴠᴡхуᴢАВСḌЕḞǴНІЈКLМΝОРQɌЅТÙⅤⱲХΥΖ'
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 mungedict = dict (zip (string.ascii_lowercase + string.ascii_uppercase, mungechars))
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 def mungeone (ch):
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 '''
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 Munges one character.
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 '''
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 try:
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 return mungedict[ch]
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 except:
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18 return ch
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 def munge (a):
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 '''
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 Munges the given string
f96730dee026 Munge the committer's name when posting a new commit to avoid highlights
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 '''
159
4c06dfae9beb Remove the license header from munge.py (LICENSE already has it)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 158
diff changeset
24 return ''.join ([mungeone (ch) for ch in a])

mercurial