emoji_clean_json.py 771 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env python3
  2. from __future__ import print_function
  3. import json
  4. import os
  5. import sys
  6. data = None
  7. with open('emoji_strategy.json') as stream:
  8. data = json.load(stream)
  9. if not data:
  10. print('Could not load the data from the JSON file')
  11. sys.exit(1)
  12. # Retrieve the items we keep in the JSON
  13. tokeep = {}
  14. for key in data:
  15. if '-' in data[key]['unicode'] and data[key]['unicode'].startswith('1F'):
  16. continue
  17. tokeep[key] = data[key]
  18. # Check if we have the keys of all images we kept
  19. unicodes = [tokeep[key]['unicode'] for key in tokeep]
  20. images = [item.replace('.png', '') for item in os.listdir('png')]
  21. print(set(unicodes).symmetric_difference(set(images)))
  22. with open('emoji_strategy2.json', 'w') as stream:
  23. json.dump(tokeep, stream)