Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move data into JSON files #302

Merged
merged 12 commits into from
Sep 19, 2024
Merged

Move data into JSON files #302

merged 12 commits into from
Sep 19, 2024

Conversation

cvzi
Copy link
Contributor

@cvzi cvzi commented Sep 13, 2024

  • Use JSON files to store the database of emoji
  • Load a language into emoji.EMOJI_DATA with emoji.config.load_language("zh")

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 TahirJalilov merged commit acfdc19 into carpedm20:master Sep 19, 2024
9 checks passed
@TahirJalilov
Copy link
Collaborator

@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
Copy link
Contributor Author

cvzi commented Sep 19, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants