utils¶
Utilities to be used by the other modules.
Byte utilities.
- class byte_bot.byte.lib.utils.FormattedRuffRule[source]¶
Bases:
BaseRuffRule
Formatted Ruff rule data.
- class byte_bot.byte.lib.utils.PEPStatus(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
StrEnum
Status of a PEP.
Note
Active
andAccepted
both traditionally useA
, but are differentiated here for clarity.Based off of PEP Status in PEP1.
- class byte_bot.byte.lib.utils.PEPType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
StrEnum
Type of PEP.
Based off of PEP Types in PEP1.
- byte_bot.byte.lib.utils.chunk_sequence(sequence: Iterable[_T], size: int) Iterable[tuple[_T, ...]] [source]¶
Naïve chunking of an iterable.
- Parameters:
sequence (Iterable[_T]) – Iterable to chunk
size (int) – Size of chunk
- Yields:
Iterable[tuple[_T, …]] – An n-tuple that contains chunked data
- byte_bot.byte.lib.utils.format_resolution_link(resolution: str | None) str [source]¶
Formats the resolution URL into a markdown link.
- byte_bot.byte.lib.utils.format_ruff_rule(rule_data: RuffRule) FormattedRuffRule [source]¶
Format ruff rule data for embed-friendly output and append rule link.
- Parameters:
rule_data – The ruff rule data.
- Returns:
The formatted rule data.
- Return type:
- byte_bot.byte.lib.utils.get_next_friday(now: datetime, delay: int | None = None) tuple[datetime, datetime] [source]¶
Calculate the next Friday from
now
.If
delay
, calculate the Friday fordelay
weeks from now.- Parameters:
now – The current date and time.
delay – The number of weeks to delay the calculation.
- Returns:
The next Friday, optionally for the week after next.
- Return type:
datetime
- byte_bot.byte.lib.utils.linker(title: str, link: str, show_embed: bool = False) str [source]¶
Create a Markdown link, optionally with an embed.
- Parameters:
title – The title of the link.
link – The URL of the link.
show_embed – Whether to show the embed or not.
- Returns:
A Markdown link.
- async byte_bot.byte.lib.utils.paste(code: str) str [source]¶
Uploads the given code to paste.pythondiscord.com.
- Parameters:
code – The formatted code to upload.
- Returns:
The URL of the uploaded paste.
- Return type:
- async byte_bot.byte.lib.utils.query_all_peps() list[PEP] [source]¶
Query all PEPs from the PEPs Python.org API.