Skip to content

Commit

Permalink
Merge pull request #302 from cvzi/json_emoji
Browse files Browse the repository at this point in the history
Move data into JSON files
  • Loading branch information
TahirJalilov committed Sep 19, 2024
2 parents e83cf4a + 740947f commit acfdc19
Show file tree
Hide file tree
Showing 44 changed files with 97,410 additions and 898 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build & test whl

on: [push]

jobs:

build-package:
name: Build & verify package
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: hynek/build-and-inspect-python-package@v2
id: baipp

outputs:
python-versions: ${{ steps.baipp.outputs.supported_python_classifiers_json_array }}

testwheel:
name: Test whl
runs-on: ubuntu-latest
needs: build-package
strategy:
max-parallel: 4
matrix:
python-version:
- "3.10"
- "3.11"
- "3.12"
- "3.13-dev"
steps:

- name: Download pre-built packages
uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- name: Extract source tarball
run: tar xf dist/*.tar.gz --strip-components=1
- name: Remove source code
run: rm -R emoji
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install tox
run: python -Im pip install tox
- name: Run tox on wheel
run: python -Im tox run --installpkg dist/*.whl
40 changes: 25 additions & 15 deletions .github/workflows/pypipublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,35 @@ on:
types: [published]

jobs:
deploy:
build-package:
name: Build & verify package
runs-on: ubuntu-latest
permissions:
id-token: write
attestations: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: hynek/build-and-inspect-python-package@v2
with:
attest-build-provenance-github: 'true'

deploy:
name: Publish to pypi.org
environment:
name: pypi
url: https://pypi.org/project/emoji/
runs-on: ubuntu-latest
needs: build-package
permissions:
id-token: write
attestations: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade build wheel
- name: Build package
run: |
python -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@v1.8.14
- name: Download package built by build-and-inspect-python-package
uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@v1.10.1
12 changes: 10 additions & 2 deletions .github/workflows/pythonTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,22 @@ jobs:
strategy:
max-parallel: 8
matrix:
python-version: [3.7, 3.8, 3.9, "3.10", "pypy-3.10", "3.11", "3.12", "3.13-dev"]
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "pypy-3.10"
- "3.11"
- "3.12"
- "3.13-dev"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Test install
- name: Install dev dependencies
run: |
python -m pip install .[dev]
- name: Test with pytest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/updateGithubPages.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: updateGithubPages
name: Update GithubPages documentation

on:
workflow_dispatch:
Expand Down
17 changes: 17 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,23 @@ with `BeautifulSoup <http://www.crummy.com/software/BeautifulSoup/>`__
and prints the contents to ``stdout`` as a Python dictionary. For more
information take a look in the `utils/README.md <utils/README.md>`__ file.

Check the code style with:

.. code-block:: console
$ python -m pip install ruff
$ ruff check emoji
Test the type checks with:

.. code-block:: console
$ python -m pip install pyright mypy typeguard
$ pyright emoji
$ pyright tests
$ mypy emoji
$ pytest --typeguard-packages=emoji
Links
-----
Expand Down
33 changes: 29 additions & 4 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,25 @@ EMOJI_DATA
:type: dict
:canonical: emoji.unicode_codes.data_dict.EMOJI_DATA

Contains all emoji as keys and their names, Unicode version and status
Contains all emoji as keys and their names, Unicode version and status.

The data is stored in JSON files: `<https://github.com/carpedm20/emoji/tree/master/emoji/unicode_codes>`_

The names in other languages than English are not loaded by default. They can be loaded with the :func:`config.load_language` function.

.. code-block:: python
EMOJI_DATA = {
'🥇': {
'en' : ':1st_place_medal:',
'status' : emoji.STATUS["fully_qualified"],
'E' : 3
},
...
}
# After config.load_language() to load more languages:
EMOJI_DATA = {
'🥇': {
'en' : ':1st_place_medal:',
Expand All @@ -81,7 +96,6 @@ EMOJI_DATA
...
}
**Source code:** `emoji/unicode_codes/data_dict.py <https://github.com/carpedm20/emoji/raw/master/emoji/unicode_codes/data_dict.py>`_ **(2MB)**
Emoji status
------------
Expand All @@ -97,9 +111,21 @@ Emoji status
.. literalinclude:: ../emoji/unicode_codes/data_dict.py
:language: python
:start-at: component =
:end-before: EMOJI_DATA
:end-before: LANGUAGES
:caption: emoji/unicode_codes/data_dict.py

.. data:: LANGUAGES
:type: dict
:canonical: emoji.unicode_codes.data_dict.LANGUAGES

All available languages, that can be used as the ``language`` parameter in :func:`emojize` and :func:`demojize`.
(Additionally the special ``"alias"`` language can be used in :func:`emojize` and :func:`demojize`).

.. literalinclude:: ../emoji/unicode_codes/data_dict.py
:language: python
:start-at: LANGUAGES:
:end-before: EMOJI_DATA
:caption: emoji/unicode_codes/data_dict.py

.. _Emoji version:

Expand All @@ -124,4 +150,3 @@ the "Data File Comment" column:
:end-before: """
:caption: Unicode/Emoji Version (emoji/unicode_codes/data_dict.py)
:dedent: 2

8 changes: 5 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
#
import os
import sys

sys.path.insert(0, os.path.abspath('..'))

# -- Project information -----------------------------------------------------

import emoji as emoji_pkg
import emoji as emoji_pkg # noqa: E402

project = 'emoji'
copyright = emoji_pkg.__source__
author = emoji_pkg.__author__
Expand Down Expand Up @@ -81,5 +83,5 @@
'All supported emoji': 'https://carpedm20.github.io/emoji/',
'All emoji on unicode.org': 'http://www.unicode.org/emoji/charts/full-emoji-list.html',
'Unicode Standard': 'http://www.unicode.org/reports/tr51/',
}
}
},
}
15 changes: 15 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,21 @@ Spanish (``'es'``), Portuguese (``'pt'``), Italian (``'it'``), French (``'fr'``)

..
If you want to access the emoji names of a language directly,
you can load the language data and then access it in the :data:`EMOJI_DATA` dict
by using the language code as a key:

.. doctest::

>>> emoji.config.load_language('es')
>>> print(emoji.EMOJI_DATA['👍']['es'])
:pulgar_hacia_arriba:

..
Note: Not all emoji have names in all languages


Extracting emoji
^^^^^^^^^^^^^^^^

Expand Down
27 changes: 20 additions & 7 deletions emoji/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
__all__ = [
# emoji.core
'emojize', 'demojize', 'analyze', 'config',
'emoji_list', 'distinct_emoji_list', 'emoji_count',
'replace_emoji', 'is_emoji', 'purely_emoji', 'version',
'Token', 'EmojiMatch', 'EmojiMatchZWJ', 'EmojiMatchZWJNonRGI',
'emojize',
'demojize',
'analyze',
'config',
'emoji_list',
'distinct_emoji_list',
'emoji_count',
'replace_emoji',
'is_emoji',
'purely_emoji',
'version',
'Token',
'EmojiMatch',
'EmojiMatchZWJ',
'EmojiMatchZWJNonRGI',
# emoji.unicode_codes
'EMOJI_DATA', 'STATUS', 'LANGUAGES',
'EMOJI_DATA',
'STATUS',
'LANGUAGES',
]

__version__ = '2.12.1'
__author__ = 'Taehoon Kim, Kevin Wurster'
__email__ = 'carpedm20@gmail.com'
# and wursterk@gmail.com, tahir.jalilov@gmail.com
__source__ = 'https://github.com/carpedm20/emoji/'
__license__ = '''
__license__ = """
New BSD License
Copyright (c) 2014-2024, Taehoon Kim, Kevin Wurster
Expand Down Expand Up @@ -42,7 +55,7 @@
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
'''
"""

from emoji.core import *
from emoji.unicode_codes import *
Loading

0 comments on commit acfdc19

Please sign in to comment.