generate-shortname-mapping.py 654 B

123456789101112131415161718192021222324
  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(('slight_smile', '🙂'))
  13. mappings.append(('slight_frown', '🙁'))
  14. print('// Generated with tools/twemoji/generate-shortname-mapping.py')
  15. print('const SHORTNAMES = {')
  16. for (k, v) in sorted(mappings):
  17. print(" '{}': '{}',".format(k, v))
  18. print('};')