bot.exts.utilities.snekbox._io#

I/O File protocols for snekbox.

Module Contents#

Classes#

FileAttachment

File Attachment from Snekbox eval.

Functions#

sizeof_fmt(→ str)

Return a human-readable file size.

normalize_discord_file_name(→ str)

Return a normalized valid discord file name.

Attributes#

bot.exts.utilities.snekbox._io.FILE_SIZE_LIMIT[source]#
bot.exts.utilities.snekbox._io.FILE_COUNT_LIMIT = 10[source]#
bot.exts.utilities.snekbox._io.RE_ANSI[source]#
bot.exts.utilities.snekbox._io.RE_BACKSLASH[source]#
bot.exts.utilities.snekbox._io.RE_DISCORD_FILE_NAME_DISALLOWED[source]#
bot.exts.utilities.snekbox._io.sizeof_fmt(num: float, suffix: str = 'B') str[source]#

Return a human-readable file size.

bot.exts.utilities.snekbox._io.normalize_discord_file_name(name: str) str[source]#

Return a normalized valid discord file name.

class bot.exts.utilities.snekbox._io.FileAttachment[source]#

File Attachment from Snekbox eval.

property suffix: str[source]#

Return the file suffix.

property name: str[source]#

Return the file name.

filename: str[source]#
content: bytes[source]#
__repr__() str[source]#

Return the content as a string.

classmethod from_dict(data: dict, size_limit: int = FILE_SIZE_LIMIT) Self[source]#

Create a FileAttachment from a dict response.

to_dict() dict[str, str][source]#

Convert the attachment to a json dict.

to_file() discord.File[source]#

Convert to a discord.File.