File: update_emoji.py

package info (click to toggle)
python-ical 12.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,776 kB
  • sloc: python: 15,157; sh: 9; makefile: 5
file content (26 lines) | stat: -rw-r--r-- 762 bytes parent folder | download
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
"""Script to import a more compact representation of the emoji library"""

from pathlib import Path
import emoji


OUTPUT_FILE = Path("ical/parsing/emoji.py")

EMOJI = list(emoji.EMOJI_DATA.keys())
HEADER = [
    """\"\"\"This file is automatically generated by script/update_emoji.py. Do not edit.\"\"\"\n\n"""
]

print("Number of emoji: {}".format(len(EMOJI)))

# Write the emoji characters to a new python file as a dictionary
with OUTPUT_FILE.open("w") as f:
    f.writelines(HEADER)
    f.write("EMOJI = [\n")
    for s in EMOJI:
        o = "".join([f"\\U{ord(ch):08x}" for ch in s])
        f.write(f"  u'{o}',  # {s}\n")
    f.write("]\n")

print("Emoji written to {}".format(OUTPUT_FILE))
print("File size: {} bytes".format(OUTPUT_FILE.stat().st_size))