scistag.emojistag.emoji_db.EmojiDb

class EmojiDb[source]

Bases: object

The Emoji DB provides Emoji and country flag graphics. By default it uses the Noto Emoji dataset embedded into the SciStag module.

Methods

find_emojis_by_name

Returns all emojis which match the defined search pattern

get_all_valid_sequences

Returns a set of all (known) valid emoji sequences

get_categories

Returns a list of all emoji main categories

get_character

type identifier

Union[str, list[str]]

get_character_sequence

Converts an emoji identifier to a unicode character sequence which can be printed to the console or a markdown document.

get_details

Returns details about am emoji

get_emojis_in_category

Returns all emojis in the defined category and subcategory

get_extensions

Returns all available emoji extensions

get_png

Tries to read the SVG of an emoji from the database

get_sequence_for_name

Returns the unicode sequence for given unicode identifier

get_sub_categories

Returns a list of all emoji sub categories of given category

get_svg

Tries to read the SVG of an emoji from the database

get_svg_support

Returns if SVG rendering is supported tne SVG repo installed

validate_sequence

Returns if given sequence is known (in the current version) of our Emoji database.

Attributes

__dict__

__doc__

__module__

__weakref__

list of weak references to the object (if defined)

_access_lock

Shared access lock

_extensions

List of known emoji addon packages

_initialized

Defines if the emoji db was initialized

_main_dict

Contains all details about every single known emoji such as name, category, subcategory and of course unicode sequence

_markdown_names

Markdown name conversion dictionary

_svg_emojis

Defines if SVG emojis are available

_unicode_names

The dictionary contains all official names of the emojis and their corresponding unicode sequence

_valid_sequences

Set of valid unicode sequences

classmethod __getitem__(key)[source]

Returns the emoji details for a specific Emoji by it’s name.

Parameters

key (str) – Either the full qualified name as defined in the unicode database or its GitHub markdown name surrounded by colons, eg “deer” or “:deer:”

Return type

EmojiInfo | None

Returns

The Emoji description

classmethod _get_main_dict()[source]

Returns the main dictionary containing all details about an emoji.

Return type

dict

Returns

The dictionary

classmethod _get_markdown_dict()[source]

Returns the markdown name dictionary. Contains all common markdown emoji names as key and their corresponding unique sequence as value

Return type

dict

Returns

The dictionary

classmethod _get_unicode_dict()[source]

Returns the unicode name dictionary. Contains all common emoji names as key and their corresponding unique sequence as value for more than 3600 emojis. See unicode.org for more details.

Return type

dict

Returns

The dictionary

classmethod find_emojis_by_name(name_mask, md=False)[source]

Returns all emojis which match the defined search pattern

Parameters
  • name_mask (str) – The name mask to search for, e.g sun

  • md (bool) – Defines if the GitHub markdown db name shall be used instead of the full unicode name list.

Returns

A list of all matching Emojis

classmethod get_all_valid_sequences()[source]

Returns a set of all (known) valid emoji sequences

:return A set of valid emoji sequences (all uppercased and with

an underscore separating the single elements)

Return type

set

classmethod get_categories()[source]

Returns a list of all emoji main categories

Return type

list[str]

Returns

A list of all known emoji categories

classmethod get_character(identifier)[source]
Parameters

identifier (Union[str, list[str]]) – The emoji’s identifier

Return type

str

Returns

The emoji character (if valid), otherwise an empty string

classmethod get_character_sequence(identifier)[source]

Converts an emoji identifier to a unicode character sequence which can be printed to the console or a markdown document.

Does not alter the value if a unicode sequence was passed already.

Parameters

identifier (Union[str, list[str]]) – The emoji identifier, either it’s unicode name, markdown name surrounded by colons or a single emoji character.

Return type

list[str]

Returns

The unicode characters

classmethod get_details(sequence)[source]

Returns details about am emoji

Parameters

sequence (list[str]) – The unicode sequence without leading zeros.

Return type

EmojiInfo | None

Returns

The EmojiInfo object if available

classmethod get_emojis_in_category(category, subcategory)[source]

Returns all emojis in the defined category and subcategory

Parameters
  • category (str) – The main category’s name as obtained by get_categories().

  • subcategory (str | None) – The name of the subcategory. If no subcategory is provided all emojis in the category will be returned.

Return type

list[EmojiInfo]

Returns

A list of all emojis in given category and subcategory

classmethod get_extensions()[source]

Returns all available emoji extensions

Return type

dict

Returns

Dictionary of extensions and their corresponding FileStag path to access their data

classmethod get_png(sequence)[source]

Tries to read the SVG of an emoji from the database

Parameters

sequence (list[str]) – The unicode sequence, e.g. [“1f98c”] for a stag

Return type

bytes | None

Returns

The SVG data on success, otherwise None

classmethod get_sequence_for_name(identifier)[source]

Returns the unicode sequence for given unicode identifier

Parameters

identifier (str) – Either the full qualified identifier as defined by unicode.org supporting all >3600 emojis as defined by unicode.org. or the markdown shortcode enclosed by two colons such as “:deer:” as defined on GitHub.

Return type

list

Returns

The unicode sequence if the emoji could be found, otherwise an empty list

classmethod get_sub_categories(category)[source]

Returns a list of all emoji sub categories of given category

Parameters

category (str) – The category’s name

Return type

list[str]

Returns

A list of subcategories in this category

classmethod get_svg(sequence)[source]

Tries to read the SVG of an emoji from the database

Parameters

sequence (list[str]) – The unicode sequence, e.g. [“u1f98c”] for a stag

Return type

bytes | None

Returns

The SVG data on success, otherwise None

classmethod get_svg_support()[source]

Returns if SVG rendering is supported tne SVG repo installed

Return type

bool

Returns

True if high quality rendering is possible

classmethod validate_sequence(sequence)[source]

Returns if given sequence is known (in the current version) of our Emoji database.

Parameters

sequence (list[str]) – The sequence as unicode characters without leading zeros.

Returns

True if the sequence is known

_access_lock = <scistag.common.mt.stag_lock.StagLock object>

Shared access lock

_extensions = {}

List of known emoji addon packages

_initialized = False

Defines if the emoji db was initialized

_main_dict = {}

Contains all details about every single known emoji such as name, category, subcategory and of course unicode sequence

_markdown_names = {}

Markdown name conversion dictionary

_svg_emojis = False

Defines if SVG emojis are available

_unicode_names = {}

The dictionary contains all official names of the emojis and their corresponding unicode sequence

_valid_sequences = {}

Set of valid unicode sequences