File: emoji_clean_json.py

package info (click to toggle)
pagure 5.11.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 15,640 kB
  • sloc: python: 113,281; javascript: 23,100; makefile: 194; sh: 66
file content (32 lines) | stat: -rw-r--r-- 784 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/python3

from __future__ import print_function, absolute_import
import json
import os
import sys

data = None
with open("emoji_strategy.json") as stream:
    data = json.load(stream)

if not data:
    print("Could not load the data from the JSON file")
    sys.exit(1)

# Retrieve the items we keep in the JSON
tokeep = {}
for key in data:
    if "-" in data[key]["unicode"] and data[key]["unicode"].startswith("1F"):
        continue
    tokeep[key] = data[key]

# Check if we have the keys of all images we kept

unicodes = [tokeep[key]["unicode"] for key in tokeep]
images = [item.replace(".png", "") for item in os.listdir("png")]

print(set(unicodes).symmetric_difference(set(images)))


with open("emoji_strategy2.json", "w") as stream:
    json.dump(tokeep, stream)