summaryrefslogtreecommitdiff
path: root/bin/emoji-list.py
blob: 9e17c300d5409bb3adeb87c0b9d97e518d21b8e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import json, os, urllib.request, urllib.parse, urllib.error
import xml.etree.ElementTree as ET

emoji_list = json.load(urllib.request.urlopen(
    'https://raw.githubusercontent.com/iamcal/emoji-data/master/emoji.json'
))
dictionary = {}
for emoji in emoji_list:
    character = ''.join([chr(int(nibble, 16)) for nibble in emoji['unified'].split('-')])
    name = emoji['name'].replace(' ', '_') if emoji['name'] else emoji['short_name'].upper().replace('-', '_')
    dictionary[character] = ' [%s] ' % (name)

stupidspeak_map = ET.fromstring(urllib.request.urlopen(
    'http://slothsoft.net/getResource.php/slothsoft/unicode-mapper'
).read())
for letter in stupidspeak_map.findall('.//letter'):
    if letter.attrib['target'] != letter.attrib['source']:
        dictionary[letter.attrib['target']] = letter.attrib['source']

json.dump(dictionary, open(os.path.join(
    os.path.dirname(os.path.realpath(__file__)),
    '../config/emoji.json'
), 'w'))