dismoji 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dismoji-0.1.0/.gitignore +175 -0
- dismoji-0.1.0/LICENSE +21 -0
- dismoji-0.1.0/PKG-INFO +98 -0
- dismoji-0.1.0/pyproject.toml +158 -0
- dismoji-0.1.0/src/dismoji/__init__.py +37 -0
- dismoji-0.1.0/src/dismoji/_version.py +21 -0
- dismoji-0.1.0/src/dismoji/py.typed +0 -0
dismoji-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
./build/ # so hatch includes discord-emojis' build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
.python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
|
|
110
|
+
# pdm
|
|
111
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
112
|
+
#pdm.lock
|
|
113
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
114
|
+
# in version control.
|
|
115
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
116
|
+
.pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
121
|
+
__pypackages__/
|
|
122
|
+
|
|
123
|
+
# Celery stuff
|
|
124
|
+
celerybeat-schedule
|
|
125
|
+
celerybeat.pid
|
|
126
|
+
|
|
127
|
+
# SageMath parsed files
|
|
128
|
+
*.sage.py
|
|
129
|
+
|
|
130
|
+
# Environments
|
|
131
|
+
.env
|
|
132
|
+
.venv
|
|
133
|
+
env/
|
|
134
|
+
venv/
|
|
135
|
+
ENV/
|
|
136
|
+
env.bak/
|
|
137
|
+
venv.bak/
|
|
138
|
+
|
|
139
|
+
# Spyder project settings
|
|
140
|
+
.spyderproject
|
|
141
|
+
.spyproject
|
|
142
|
+
|
|
143
|
+
# Rope project settings
|
|
144
|
+
.ropeproject
|
|
145
|
+
|
|
146
|
+
# mkdocs documentation
|
|
147
|
+
/site
|
|
148
|
+
|
|
149
|
+
# mypy
|
|
150
|
+
.mypy_cache/
|
|
151
|
+
.dmypy.json
|
|
152
|
+
dmypy.json
|
|
153
|
+
|
|
154
|
+
# Pyre type checker
|
|
155
|
+
.pyre/
|
|
156
|
+
|
|
157
|
+
# pytype static type analyzer
|
|
158
|
+
.pytype/
|
|
159
|
+
|
|
160
|
+
# Cython debug symbols
|
|
161
|
+
cython_debug/
|
|
162
|
+
|
|
163
|
+
# PyCharm
|
|
164
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
165
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
166
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
167
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
168
|
+
.idea/
|
|
169
|
+
|
|
170
|
+
# PyPI configuration file
|
|
171
|
+
.pypirc
|
|
172
|
+
|
|
173
|
+
_version.py
|
|
174
|
+
|
|
175
|
+
node_modules/
|
dismoji-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Paillat-dev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
dismoji-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dismoji
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: ***
|
|
5
|
+
Project-URL: Homepage, https://github.com/Paillat-dev/dismoji
|
|
6
|
+
Project-URL: source_archive, https://github.com/Paillat-dev/dismoji/archive/ab6b493057d327dc84552c32c00d1c80aa2ed92f.zip
|
|
7
|
+
Author-email: Paillat-dev <me@paillat.dev>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: bot,discord,emoji,emojis
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: ==3.12.*
|
|
23
|
+
Requires-Dist: json5>=0.12.0
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+

|
|
28
|
+

|
|
29
|
+

|
|
30
|
+

|
|
31
|
+

|
|
32
|
+
[](https://results.pre-commit.ci/latest/github/Paillat-dev/dismoji/main)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
dismoji is a lightweight Python library that provides a simple way to convert Discord
|
|
38
|
+
emoji names to their Unicode equivalents. With just a single function call, you can
|
|
39
|
+
transform text containing Discord-style emoji codes (like `:smile:`) into text with
|
|
40
|
+
actual Unicode emoji characters (like "😄").
|
|
41
|
+
|
|
42
|
+
This library uses
|
|
43
|
+
[Paillat-dev/discord-emojis](https://github.com/Paillat-dev/discord-emojis) as the
|
|
44
|
+
source for Discord emoji names and aliases.
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
import dismoji
|
|
49
|
+
|
|
50
|
+
# Convert Discord emoji names to Unicode emojis
|
|
51
|
+
text = "Hello, :wave: I'm excited! :partying_face:"
|
|
52
|
+
converted_text = dismoji.emojize(text)
|
|
53
|
+
print(converted_text) # Output: "Hello, 👋 I'm excited! 🥳"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Features
|
|
57
|
+
|
|
58
|
+
- **Simple API**: Just one function to remember - `dismoji.emojize()`
|
|
59
|
+
- **Discord Compatible**: Supports Discord's emoji naming conventions
|
|
60
|
+
- **Comprehensive**: Includes all standard emojis available on Discord
|
|
61
|
+
- **Type Safe**: Fully type-annotated for better IDE integration
|
|
62
|
+
- **Zero Dependencies**: Lightweight with no external dependencies
|
|
63
|
+
- **Fast**: Optimized for quick emoji replacement
|
|
64
|
+
|
|
65
|
+
## Getting Help
|
|
66
|
+
|
|
67
|
+
If you encounter issues or have questions about dismoji:
|
|
68
|
+
|
|
69
|
+
- **GitHub Issues**:
|
|
70
|
+
[Submit a bug report or feature request](https://github.com/Paillat-dev/dismoji/issues)
|
|
71
|
+
- **Discord Support**: Join the [Pycord Official Server](https://discord.gg/pycord) and
|
|
72
|
+
mention `@paillat`
|
|
73
|
+
|
|
74
|
+
## Development
|
|
75
|
+
|
|
76
|
+
### Contributing
|
|
77
|
+
|
|
78
|
+
1. Fork the repository
|
|
79
|
+
2. Create a feature branch
|
|
80
|
+
3. Make your changes
|
|
81
|
+
4. Run linter, formatter and type checker: `ruff check .`, `ruff format .`,
|
|
82
|
+
`basedpyright .`
|
|
83
|
+
5. Submit a pull request
|
|
84
|
+
|
|
85
|
+
**Development Tools**:
|
|
86
|
+
|
|
87
|
+
- **uv**: For dependency management
|
|
88
|
+
- **Ruff**: For linting and formatting
|
|
89
|
+
- **HashiCorp Copywrite**: For managing license headers
|
|
90
|
+
- **basedpyright**: For type checking
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
MIT License - Copyright (c) 2025 Paillat-dev
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
Made with ❤ by Paillat-dev
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling", "hatch-vcs", "hatch-fancy-pypi-readme"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "dismoji"
|
|
7
|
+
dynamic = ["version", "urls", "readme"]
|
|
8
|
+
description = "***"
|
|
9
|
+
authors = [
|
|
10
|
+
{ name = "Paillat-dev", email = "me@paillat.dev" }
|
|
11
|
+
]
|
|
12
|
+
license = "MIT"
|
|
13
|
+
requires-python = "==3.12.*"
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
19
|
+
"Programming Language :: Python :: 3.13",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.9",
|
|
24
|
+
"Typing :: Typed",
|
|
25
|
+
"Operating System :: OS Independent",
|
|
26
|
+
]
|
|
27
|
+
keywords = ["discord", "bot", "emojis", "emoji"]
|
|
28
|
+
dependencies = [
|
|
29
|
+
"json5>=0.12.0",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[dependency-groups]
|
|
33
|
+
dev = [
|
|
34
|
+
"basedpyright>=1.28.1",
|
|
35
|
+
"pytest>=8.3.5",
|
|
36
|
+
"python-dotenv>=1.0.1",
|
|
37
|
+
"ruff>=0.9.9",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
[tool.hatch.version]
|
|
41
|
+
source = "vcs"
|
|
42
|
+
|
|
43
|
+
[tool.hatch.build.hooks.vcs]
|
|
44
|
+
version-file = "src/dismoji/_version.py"
|
|
45
|
+
|
|
46
|
+
[tool.hatch.metadata.hooks.vcs.urls]
|
|
47
|
+
Homepage = "https://github.com/Paillat-dev/dismoji"
|
|
48
|
+
source_archive = "https://github.com/Paillat-dev/dismoji/archive/{commit_hash}.zip"
|
|
49
|
+
|
|
50
|
+
[tool.hatch.metadata.hooks.fancy-pypi-readme]
|
|
51
|
+
content-type = "text/markdown"
|
|
52
|
+
|
|
53
|
+
[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
|
|
54
|
+
path = "README.md"
|
|
55
|
+
start-after = "<!-- badges -->\n"
|
|
56
|
+
end-before = "\n<!-- end badges -->"
|
|
57
|
+
|
|
58
|
+
[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
|
|
59
|
+
text = "\n\n---\n"
|
|
60
|
+
|
|
61
|
+
[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
|
|
62
|
+
path = "README.md"
|
|
63
|
+
start-after = "## Overview\n"
|
|
64
|
+
end-before = "\n## Installation"
|
|
65
|
+
|
|
66
|
+
[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
|
|
67
|
+
path = "README.md"
|
|
68
|
+
start-after = "<!-- quick-start -->"
|
|
69
|
+
|
|
70
|
+
[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
|
|
71
|
+
pattern = '\[(.+?)\]\(((?!https?://)\S+?)\)'
|
|
72
|
+
replacement = '[\1](https://github.com/Paillat-dev/dismoji/tree/main\g<2>)'
|
|
73
|
+
|
|
74
|
+
[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
|
|
75
|
+
pattern = '\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]'
|
|
76
|
+
replacement = '**\1**:'
|
|
77
|
+
|
|
78
|
+
[tool.hatchling]
|
|
79
|
+
name = "dismoji"
|
|
80
|
+
|
|
81
|
+
[tool.hatch.build]
|
|
82
|
+
include = [
|
|
83
|
+
"src/dismoji/",
|
|
84
|
+
"src/dismoji/raw/build/emojis.json",
|
|
85
|
+
]
|
|
86
|
+
exclude = [
|
|
87
|
+
".copywrite.hcl",
|
|
88
|
+
".github",
|
|
89
|
+
".python-version",
|
|
90
|
+
"uv.lock",
|
|
91
|
+
"src/dismoji/raw/*.*",
|
|
92
|
+
"src/dismoji/raw/.*/",
|
|
93
|
+
"src/dismoji/raw/src/"
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
[tool.hatch.build.targets.wheel]
|
|
97
|
+
packages = ["src/dismoji"]
|
|
98
|
+
|
|
99
|
+
[tool.pyright]
|
|
100
|
+
pythonVersion = "3.9"
|
|
101
|
+
typeCheckingMode = "all"
|
|
102
|
+
reportUnusedCallResult = false
|
|
103
|
+
reportAny = false
|
|
104
|
+
executionEnvironments = [
|
|
105
|
+
{ root = "src/dismoji/_version.py", reportDeprecated = false },
|
|
106
|
+
{ root = "examples", reportExplicitAny = false, reportUnknownMemberType = false, reportUnusedParameter = false, reportImplicitOverride = false }
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
[tool.ruff]
|
|
110
|
+
target-version = "py39"
|
|
111
|
+
line-length = 120
|
|
112
|
+
indent-width = 4
|
|
113
|
+
|
|
114
|
+
[tool.ruff.format]
|
|
115
|
+
quote-style = "double"
|
|
116
|
+
indent-style = "space"
|
|
117
|
+
skip-magic-trailing-comma = false
|
|
118
|
+
line-ending = "auto"
|
|
119
|
+
docstring-code-format = false
|
|
120
|
+
docstring-code-line-length = "dynamic"
|
|
121
|
+
exclude = [
|
|
122
|
+
"src/dismoji/_version.py"
|
|
123
|
+
]
|
|
124
|
+
|
|
125
|
+
[tool.ruff.lint]
|
|
126
|
+
select = ["ALL"]
|
|
127
|
+
per-file-ignores = { "examples/**/*" = ["INP001", "ARG002", "T201"], "tests/**/*" = ["S101"], "src/dismoji/_version.py" = ["I001", "Q000", "UP005", "UP006", "UP035"] }
|
|
128
|
+
extend-ignore = [
|
|
129
|
+
"N999",
|
|
130
|
+
"D104",
|
|
131
|
+
"D100",
|
|
132
|
+
"D103",
|
|
133
|
+
"D102",
|
|
134
|
+
"D101",
|
|
135
|
+
"D107",
|
|
136
|
+
"D105",
|
|
137
|
+
"D106",
|
|
138
|
+
"ANN401",
|
|
139
|
+
"TRY003",
|
|
140
|
+
"EM101",
|
|
141
|
+
"EM102",
|
|
142
|
+
"G004",
|
|
143
|
+
"PTH",
|
|
144
|
+
"D211",
|
|
145
|
+
"D213",
|
|
146
|
+
"COM812",
|
|
147
|
+
"ISC001",
|
|
148
|
+
"D203",
|
|
149
|
+
"FBT001",
|
|
150
|
+
"FBT002",
|
|
151
|
+
"PLR2004",
|
|
152
|
+
"PLR0913",
|
|
153
|
+
"C901",
|
|
154
|
+
"ISC003" # conflicts with basedpyright reportImplicitStringConcatenation
|
|
155
|
+
]
|
|
156
|
+
|
|
157
|
+
[tool.uv.sources]
|
|
158
|
+
py-cord = { git = "https://github.com/Pycord-Development/pycord", rev = "c0c0b7c58f7b489983a159f5e0eea2c0dab0b0c8" }
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Copyright (c) Paillat-dev
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import json
|
|
7
|
+
import re
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
EMOJIS_PATH = Path(__file__).parent / "raw" / "build" / "emojis.json"
|
|
11
|
+
|
|
12
|
+
with EMOJIS_PATH.open("r", encoding="utf-8") as f:
|
|
13
|
+
EMOJIS = json.load(f)
|
|
14
|
+
|
|
15
|
+
EMOJI_MAPPING: dict[str, str] = {k: EMOJIS["emojis"][v]["surrogates"] for k, v in EMOJIS["nameToEmoji"].items()}
|
|
16
|
+
|
|
17
|
+
EMOJI_PATTERN = re.compile(r"(?<!\w):([a-zA-Z0-9_-]+):(?!\w)")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def emojize(s: str) -> str:
|
|
21
|
+
"""Convert a string with emoji names to a string with emoji characters.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
s (str): The input string containing emoji names.
|
|
25
|
+
|
|
26
|
+
Returns:
|
|
27
|
+
str: The input string with emoji names replaced by emoji characters.
|
|
28
|
+
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def replace(match: re.Match[str]) -> str:
|
|
32
|
+
emoji_name = match.group(1)
|
|
33
|
+
if emoji_name in EMOJI_MAPPING:
|
|
34
|
+
return EMOJI_MAPPING[emoji_name]
|
|
35
|
+
return match.group(0)
|
|
36
|
+
|
|
37
|
+
return EMOJI_PATTERN.sub(replace, s)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# file generated by setuptools-scm
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
|
|
4
|
+
__all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
|
|
5
|
+
|
|
6
|
+
TYPE_CHECKING = False
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from typing import Tuple
|
|
9
|
+
from typing import Union
|
|
10
|
+
|
|
11
|
+
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
12
|
+
else:
|
|
13
|
+
VERSION_TUPLE = object
|
|
14
|
+
|
|
15
|
+
version: str
|
|
16
|
+
__version__: str
|
|
17
|
+
__version_tuple__: VERSION_TUPLE
|
|
18
|
+
version_tuple: VERSION_TUPLE
|
|
19
|
+
|
|
20
|
+
__version__ = version = '0.1.0'
|
|
21
|
+
__version_tuple__ = version_tuple = (0, 1, 0)
|
|
File without changes
|