-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathweirdify.py
More file actions
38 lines (25 loc) · 699 Bytes
/
Copy pathweirdify.py
File metadata and controls
38 lines (25 loc) · 699 Bytes
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
28
29
30
31
32
33
34
35
36
37
38
# -*- encoding: utf-8 -*-
import os
import sys
import random
import unicodedata
import collections
WEIRDNESS = 18
conversions = collections.defaultdict(list)
input_chars = [chr(i) for i in range(ord('z') + 1, WEIRDNESS * 1000)]
def normalize(char):
return unicodedata.normalize('NFKD', char)
for char in input_chars:
n = normalize(char)
if n:
conversions[n].append(char)
def convert(text):
return ''.join([random.choice(conversions.get(c, [c])) for c in text])
def usage():
print('Usage: {} "[Text to convert]"'.format(sys.argv[0]))
sys.exit(os.EX_USAGE)
if len(sys.argv) < 2:
usage()
else:
text = ' '.join(sys.argv[1:])
print(convert(text))