1
0

emoji_clean_json.py 732 B

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