carpedm20 / emoji

emoji terminal output for Python
Other
1.9k stars 279 forks source link

Move data into JSON files #302

Closed cvzi closed 2 months ago

cvzi commented 2 months ago

All the data from EMOJI_DATA is moved into JSON files: The metadata and the English names and aliases are in emoji.json The other languages have individual files e.g. emoji_fr.json The literal EMOJI_DATA in Python is removed. I left a small part of it in place for documentation, but it is not used.

By default only emoji.json is loaded into EMOJI_DATA, so only English and aliases. If you call emoji.emojize() or emoji.demojize() with a language parameter, then the language is loaded automatically.

Only if you access the EMOJI_DATA directly, you need to load the language first. For this there is a new function emoji.config.load_language('fr'). However to avoid this being a breaking change, I have added the magic __missing__(key) method to the EMOJI_DATA dictionary: https://github.com/cvzi/emoji/blob/json_emoji/emoji/unicode_codes/__init__.py#L59-L72 This will automatically load the language, e.g. if you access EMOJI_DATA['❤️']['fr'] it will automatically load French. It will only show a deprecation warning, that you should use emoji.config.load_language. In the next version this can be removed and then EMOJI_DATA['❤️']['fr'] will raise an Exception if French was not loaded beforehand.

I formatted the code with the ruff tool, that's why all files have changes, so you better look at the individual commits if you want to check what I have changed.

TahirJalilov commented 2 months ago

@cvzi There is an error with uploading package to pypi

WARNING  Error during upload. Retry with the --verbose option for more details. 
ERROR    HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/   
cvzi commented 2 months ago

Version number in init.py needs to be increased. Hopefully that's the only problem