ssb: Update emojis.json, and add a script to regenerate it.
Some checks are pending
Build Tilde Friends / Build-All (push) Waiting to run
Some checks are pending
Build Tilde Friends / Build-All (push) Waiting to run
This commit is contained in:
parent
7f4e2617ee
commit
51912f2b83
File diff suppressed because one or more lines are too long
30
tools/emojis.py
Executable file
30
tools/emojis.py
Executable file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import urllib.request
|
||||
|
||||
if not os.path.exists('out/emoji-test.txt'):
|
||||
urllib.request.urlretrieve('https://unicode.org/Public/emoji/latest/emoji-test.txt', 'out/emoji-test.txt')
|
||||
|
||||
doc = {}
|
||||
|
||||
with open('out/emoji-test.txt', 'r') as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line.startswith('# group: '):
|
||||
group = line[len('# group: '):]
|
||||
elif line.startswith('# subgroup: '):
|
||||
subgroup = line[len('# subgroup: '):]
|
||||
else:
|
||||
m = re.match(r'((?:\s?[0-9A-F]+)+)\s+;.*#.*E\d+\.\d+ (.*)', line)
|
||||
if m:
|
||||
emoji = ''.join(chr(int(g, 16)) for g in m.group(1).split(' '))
|
||||
name = m.group(2)
|
||||
if not group in doc:
|
||||
doc[group] = {}
|
||||
doc[group][name] = emoji
|
||||
|
||||
with open('apps/ssb/emojis.json', 'w') as f:
|
||||
json.dump(doc, f, ensure_ascii = False)
|
Loading…
Reference in New Issue
Block a user