generate-shortname-mapping.py 603 B

1234567891011121314151617181920212223
  1. #!/usr/bin/env python3
  2. import json
  3. GROUPS_JSON = '../../../twemoji-picker/generated/groups.json'
  4. with open(GROUPS_JSON, 'r') as f:
  5. groups = json.loads(f.read())
  6. mappings = []
  7. for emoji_list in groups.values():
  8. for emoji in emoji_list:
  9. for shortname in emoji['shortnames']:
  10. mappings.append((shortname.strip(':'), emoji['emoji']))
  11. # Custom shortcodes
  12. mappings.append(('joy', '😂'))
  13. print('// Generated with tools/twemoji/generate-shortname-mapping.py')
  14. print('const SHORTNAMES = {')
  15. for (k, v) in sorted(mappings):
  16. print(" '{}': '{}',".format(k, v))
  17. print('};')