munge.py

Mon, 11 Jan 2016 18:29:14 +0200

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Mon, 11 Jan 2016 18:29:14 +0200
changeset 164
e18f73e4c2e2
parent 162
d24fe5e3e420
permissions
-rw-r--r--

More Python 3 support

#!/usr/bin/env python3
# encoding: utf-8
'''
Provides the munge function.
'''

import string
mungechars = 'аɓᴄđеƒɡɦіјķɭṁɳорqŗѕƫᴜᴠᴡхуᴢАВСḌЕḞǴНІЈКLМΝОРQɌЅТÙⅤⱲХΥΖ'
mungedict = dict (zip (string.ascii_lowercase + string.ascii_uppercase, mungechars))

def mungeone (ch):
	'''
	Munges one character.
	'''
	try:
		return mungedict[ch]
	except:
		return ch

def munge (a):
	'''
	Munges the given string
	'''
	return ''.join (mungeone(ch) for ch in a)

mercurial