generate-shortname-mapping.py 497 B

12345678910111213141516171819
  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['codepoint_fully_qualified']))
  11. print('const shortnames = {')
  12. for (k, v) in sorted(mappings):
  13. print(" '{}': '{}',".format(k, v))
  14. print('}')