mirror of
https://github.com/Paillat-dev/dismoji.git
synced 2026-01-02 17:14:55 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a1d2592ee1 | |||
| 6dc46f06d6 | |||
| 8af0deea07 | |||
| 2014fb4a61 |
@@ -120,6 +120,7 @@ exclude = [
|
|||||||
"src/dismoji/_version.py"
|
"src/dismoji/_version.py"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
[tool.ruff.lint]
|
[tool.ruff.lint]
|
||||||
select = ["ALL"]
|
select = ["ALL"]
|
||||||
per-file-ignores = { "examples/**/*" = ["INP001", "ARG002", "T201"], "tests/**/*" = ["S101"], "src/dismoji/_version.py" = ["I001", "Q000", "UP005", "UP006", "UP035"] }
|
per-file-ignores = { "examples/**/*" = ["INP001", "ARG002", "T201"], "tests/**/*" = ["S101"], "src/dismoji/_version.py" = ["I001", "Q000", "UP005", "UP006", "UP035"] }
|
||||||
@@ -151,6 +152,7 @@ extend-ignore = [
|
|||||||
"C901",
|
"C901",
|
||||||
"ISC003" # conflicts with basedpyright reportImplicitStringConcatenation
|
"ISC003" # conflicts with basedpyright reportImplicitStringConcatenation
|
||||||
]
|
]
|
||||||
|
pydocstyle.convention = "google"
|
||||||
|
|
||||||
[tool.uv.sources]
|
[tool.uv.sources]
|
||||||
py-cord = { git = "https://github.com/Pycord-Development/pycord", rev = "c0c0b7c58f7b489983a159f5e0eea2c0dab0b0c8" }
|
py-cord = { git = "https://github.com/Pycord-Development/pycord", rev = "c0c0b7c58f7b489983a159f5e0eea2c0dab0b0c8" }
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ with EMOJIS_PATH.open("r", encoding="utf-8") as f:
|
|||||||
|
|
||||||
EMOJI_MAPPING: dict[str, str] = {k: EMOJIS["emojis"][v]["surrogates"] for k, v in EMOJIS["nameToEmoji"].items()}
|
EMOJI_MAPPING: dict[str, str] = {k: EMOJIS["emojis"][v]["surrogates"] for k, v in EMOJIS["nameToEmoji"].items()}
|
||||||
|
|
||||||
EMOJI_PATTERN = re.compile(r"(?<!\w):([a-zA-Z0-9_-]+):(?!\w)")
|
del EMOJIS # Clean up to save memory
|
||||||
|
|
||||||
|
EMOJI_PATTERN = re.compile(r":([a-zA-Z0-9_-]+):")
|
||||||
|
|
||||||
|
|
||||||
def emojize(s: str) -> str:
|
def emojize(s: str) -> str:
|
||||||
|
|||||||
Submodule src/dismoji/raw updated: f4c3abf844...079afc968f
@@ -41,3 +41,30 @@ def test_multiple_emojis() -> None:
|
|||||||
def test_complex_sentence() -> None:
|
def test_complex_sentence() -> None:
|
||||||
"""Test emojize function with a complex sentence."""
|
"""Test emojize function with a complex sentence."""
|
||||||
assert emojize("Hello :wave:, what's up? :smile: :white_check_mark: :smile:") == "Hello 👋, what's up? 😄 ✅ 😄"
|
assert emojize("Hello :wave:, what's up? :smile: :white_check_mark: :smile:") == "Hello 👋, what's up? 😄 ✅ 😄"
|
||||||
|
|
||||||
|
|
||||||
|
def test_spaces() -> None:
|
||||||
|
"""Test emojize function with spaces."""
|
||||||
|
space_tests = [
|
||||||
|
("Hello :smile::smile:", "Hello 😄😄"),
|
||||||
|
("Hii what's up :wave:?", "Hii what's up 👋?"),
|
||||||
|
("Hello:wave: :smile:", "Hello👋 😄"),
|
||||||
|
("Hellooo :wave:hru?", "Hellooo 👋hru?"),
|
||||||
|
("Hii:wave:hru?", "Hii👋hru?"),
|
||||||
|
]
|
||||||
|
for input_str, expected_output in space_tests:
|
||||||
|
assert emojize(input_str) == expected_output
|
||||||
|
|
||||||
|
|
||||||
|
def test_emoji_with_special_characters() -> None:
|
||||||
|
"""Test emojize function with special characters."""
|
||||||
|
special_char_tests = [
|
||||||
|
("Hello :smile:!", "Hello 😄!"),
|
||||||
|
("Hello :smile:?", "Hello 😄?"),
|
||||||
|
("Hello :smile::smile:!", "Hello 😄😄!"),
|
||||||
|
("Hello :smile::smile:?", "Hello 😄😄?"),
|
||||||
|
("Hello :smile::smile::smile:!", "Hello 😄😄😄!"),
|
||||||
|
("Hello :smile::smile::smile:?", "Hello 😄😄😄?"),
|
||||||
|
]
|
||||||
|
for input_str, expected_output in special_char_tests:
|
||||||
|
assert emojize(input_str) == expected_output
|
||||||
|
|||||||
Reference in New Issue
Block a user