emoji_data.sequence module

final class emoji_data.sequence.EmojiSequence(code_points: int | Iterable[int], type_field: str | None = None, version: str | None = None, variation: str | None = None, description: str | None = None)[source]

Bases: object

Emoji and Text Presentation Sequences used to represent emoji

Parameters:
  • code_points (Union[int, Iterable[int]])

  • type_field (Optional[str])

  • version (Optional[str])

  • variation (Optional[str])

  • description (Optional[str])

pattern: ClassVar[Pattern[str]] = re.compile('\\U0001F468\\U0001F3FB\\u200D\\u2764\\uFE0F\\u200D\\U0001F48B\\u200D\\U0001F468\\U0001F3FB|\\U0001F468\\U0001F3FB\\u200D\\u2764\\uFE0F\\u200D\\U0001F48B\\u200D\\U0001F468\\U0001F3FC|\\U0001F468\\U000)

Compiled regular expression pattern object for all-together Emoji sequences.

classmethod initial()[source]

Initial the class

Load Emoji Sequences from package data file into class internal dictionary

classmethod release()[source]
classmethod items() Iterator[Tuple[str, Self]][source]

Returns an iterator of all string -> emoji-sequence pairs of the class

Return type:

Iterator[Tuple[str, Self]]

classmethod keys() Iterator[str][source]

Returns an iterator of each emoji-sequence’s key string of the class

Return type:

Iterator[str]

classmethod values() Iterator[Self][source]

Returns an iterator of all emoji-sequences of the class

Return type:

Iterator[Self]

classmethod from_string(s: str) Self[source]

Get an EmojiSequence instance from string

Parameters:

s (str) – Emoji string

Returns:

Instance from internal dictionary

Raises:

KeyError – When passed-in s not found in internal dictionary

Return type:

Self

classmethod from_characters(value: EmojiCharacter | Iterable[EmojiCharacter]) Self[source]

Get an EmojiSequence instance from EmojiCharacter object or list

Parameters:

value (EmojiCharacter | Iterable[EmojiCharacter]) – Single or iterable object of EmojiCharacter, composing the sequence

Returns:

Instance from internal dictionary

Raises:
Return type:

Self

classmethod from_hex(value: int | str | Iterable[int | str]) Self[source]

Get an EmojiSequence instance by unicode code point(s)

Parameters:

value (int | str | Iterable[int | str]) –

A single or sequence of HEX string/code.

it could be:

  • one or more code-point(s) in HEX format string, separated by spaces

  • a single code-point integer

  • An iterable object whose members are code-point string in HEX format

  • An iterable object whose members are code-point integer

Returns:

Instance returned from the class’s internal dictionary

Raises:

KeyError – When passed-in value not found in the class internal dictionary

Return type:

Self

property type_field: str

A convenience for parsing the emoji sequence files, and is not intended to be maintained as a property.

may be one of:

  • “Basic_Emoji”

  • “Emoji_Keycap_Sequence”

  • “Emoji_Flag_Sequence”

  • “Emoji_Tag_Sequence”

  • “Emoji_Modifier_Sequence”

  • “RGI_Emoji_ZWJ_Sequence”

property description: str

Description

property version: str

Version of the Emoji.

Example

E0.0, E0.6, E11.0

property variation: str

"emoji style" or "text style" of a variable sequence

property characters: Sequence[EmojiCharacter]

Emoji character objects list which makes up the Emoji Sequence

property hex: str

Python style hex string of each emoji-characters’s code-point, separated by spaces

Example

"0xa9 0xfe0f"

property string: str

string of the Emoji Sequence

property regex: str

Regular expression string of the Emoji Sequence

property regex_pattern

Compiled regular expression pattern of the Emoji Sequence

property code_points: Sequence[int]

List of unicode integer value of the characters who make up this Emoji Sequence

property code_points_string: str

Unicode style hex string of each emoji-characters’s code-point, separated by spaces

eg: "00A9 FE0F"

classmethod find_all(s: str) Sequence[Tuple[Self, int, int]][source]

Find out all emoji sequences in a string, and return them in a list

Items of the returned list is the same as yield result of find()

The function equals:

list(EmojiSequence.find(s))

or

[x for x in EmojiSequence.find(s)]
Parameters:

s (str)

Return type:

Sequence[Tuple[Self, int, int]]

classmethod find(s: str) Generator[Tuple[Self, int, int], None, None][source]

Return an iterator which yields all emoji sequences in a string, without actually storing them all simultaneously.

Parameters:

s (str) – The string to find emoji sequences in it

Yields:

Yields at every matched emoji sequence as a 3-members tuple, whose members are:

  1. The found EmojiSequence object

  2. Begin position of the emoji sequence in the string

  3. End position of the emoji sequence in the string

Return type:

Generator[Tuple[Self, int, int], None, None]