1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-30 19:46:25 +00:00
bazarr/libs/rich/_emoji_replace.py
Michiel van Baak Jansen 4a0932b5d3
Update ffsubsync and srt module
* Update ffsubsync to 0.4.11
* Update srt to 3.4.1
2021-04-13 00:02:29 -04:00

17 lines
462 B
Python

from typing import Match
import re
from ._emoji_codes import EMOJI
def _emoji_replace(text: str, _emoji_sub=re.compile(r"(:(\S*?):)").sub) -> str:
"""Replace emoji code in text."""
get_emoji = EMOJI.get
def do_replace(match: Match[str]) -> str:
"""Called by re.sub to do the replacement."""
emoji_code, emoji_name = match.groups()
return get_emoji(emoji_name.lower(), emoji_code)
return _emoji_sub(do_replace, text)