emoji_data.sequence module

class emoji_data.sequence.EmojiSequence

Bases: object

Emoji and Text Presentation Sequences used to represent emoji

see: http://www.unicode.org/reports/tr51/#Emoji_Sequences

__init__(code_points, type_field='', description='', comment='')
Parameters:
pattern: Pattern = 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()

Initial the class

Load Emoji Sequences from package data file into class internal dictionary

classmethod release()
classmethod items()

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

Return type:

Iterable[Tuple[str, EmojiSequence]]

classmethod keys()

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

Return type:

Iterable[str]

classmethod values()

Return an iterator of all emoji-sequences of the class

Return type:

Iterable[EmojiSequence]

classmethod from_string(s)

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:

EmojiSequence

classmethod from_characters(value)

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:

EmojiSequence

classmethod from_hex(value)

Get an EmojiSequence instance by unicode code point(s)

Parameters:

value (Union[str, int, Iterable[str], Iterable[int]]) –

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:

EmojiSequence

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
property comment: str
property characters: List[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

eg: 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: List[int]

List of unicode integer value of the characters who make up 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)

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

Item of the returned list is as same as that in the iterator of find()

The function equals:

list(EmojiSequence.find(s))

or

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

s (str) –

Return type:

List[Tuple[EmojiSequence, int, int]]

classmethod find(s)

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

Returns:

Item of the iterator is a 3-member tuple:

  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:

Iterable[Tuple[EmojiSequence, int, int]]