mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Update docs
This commit is contained in:
parent
04151d337a
commit
0f85279561
20 changed files with 83 additions and 28 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -164,7 +164,12 @@
|
|||
<dl class="method">
|
||||
<dt id="royalnet.bots.TelegramBot._call_factory">
|
||||
<code class="descname">_call_factory</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → Type[royalnet.utils.call.Call]<a class="headerlink" href="#royalnet.bots.TelegramBot._call_factory" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Create the TelegramCall class, representing a command call. It should inherit from :py:class`royalnet.utils.Call`.</p>
|
||||
<dd><p>Create the TelegramCall class, representing a command call. It should inherit from <a class="reference internal" href="utils.html#royalnet.utils.Call" title="royalnet.utils.Call"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.utils.Call</span></code></a>.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Returns</dt>
|
||||
<dd class="field-odd"><p>The created TelegramCall class.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
|
@ -215,13 +220,18 @@
|
|||
<dl class="method">
|
||||
<dt id="royalnet.bots.DiscordBot._call_factory">
|
||||
<code class="descname">_call_factory</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → Type[royalnet.utils.call.Call]<a class="headerlink" href="#royalnet.bots.DiscordBot._call_factory" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Create the TelegramCall class, representing a command call. It should inherit from :py:class`royalnet.utils.Call`.</p>
|
||||
<dd><p>Create the TelegramCall class, representing a command call. It should inherit from <a class="reference internal" href="utils.html#royalnet.utils.Call" title="royalnet.utils.Call"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.utils.Call</span></code></a>.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Returns</dt>
|
||||
<dd class="field-odd"><p>The created TelegramCall class.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="royalnet.bots.DiscordBot._init_client">
|
||||
<code class="descname">_init_client</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.DiscordBot._init_client" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Create an instance of the DiscordClient class created in <code class="xref py py-func docutils literal notranslate"><span class="pre">royalnet.bots.discord._bot_factory()</span></code>.</p>
|
||||
<dd><p>Create an instance of the DiscordClient class created in <a class="reference internal" href="#royalnet.bots.DiscordBot._bot_factory" title="royalnet.bots.DiscordBot._bot_factory"><code class="xref py py-func docutils literal notranslate"><span class="pre">royalnet.bots.DiscordBot._bot_factory()</span></code></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
|
@ -265,7 +275,7 @@
|
|||
<dl class="class">
|
||||
<dt id="royalnet.bots.DiscordConfig">
|
||||
<em class="property">class </em><code class="descclassname">royalnet.bots.</code><code class="descname">DiscordConfig</code><span class="sig-paren">(</span><em>token: str</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.DiscordConfig" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>The specific configuration to be used for <code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.database.DiscordBot</span></code>.</p>
|
||||
<dd><p>The specific configuration to be used for <a class="reference internal" href="#royalnet.bots.DiscordBot" title="royalnet.bots.DiscordBot"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.bots.DiscordBot</span></code></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
|
@ -275,19 +285,24 @@
|
|||
<dl class="method">
|
||||
<dt id="royalnet.bots.GenericBot._call_factory">
|
||||
<code class="descname">_call_factory</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → Type[royalnet.utils.call.Call]<a class="headerlink" href="#royalnet.bots.GenericBot._call_factory" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Create the TelegramCall class, representing a command call. It should inherit from :py:class`royalnet.utils.Call`.</p>
|
||||
<dd><p>Create the TelegramCall class, representing a command call. It should inherit from <a class="reference internal" href="utils.html#royalnet.utils.Call" title="royalnet.utils.Call"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.utils.Call</span></code></a>.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Returns</dt>
|
||||
<dd class="field-odd"><p>The created TelegramCall class.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="royalnet.bots.GenericBot._init_commands">
|
||||
<code class="descname">_init_commands</code><span class="sig-paren">(</span><em>command_prefix: str, commands: List[Type[royalnet.utils.command.Command]], missing_command: Type[royalnet.utils.command.Command], error_command: Type[royalnet.utils.command.Command]</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.GenericBot._init_commands" title="Permalink to this definition">¶</a></dt>
|
||||
<code class="descname">_init_commands</code><span class="sig-paren">(</span><em>command_prefix: str, commands: List[Type[royalnet.utils.command.Command]], missing_command: Type[royalnet.utils.command.Command], error_command: Type[royalnet.utils.command.Command]</em><span class="sig-paren">)</span> → None<a class="headerlink" href="#royalnet.bots.GenericBot._init_commands" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Generate the <code class="docutils literal notranslate"><span class="pre">commands</span></code> dictionary required to handle incoming messages, and the <code class="docutils literal notranslate"><span class="pre">network_handlers</span></code> dictionary required to handle incoming requests.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="royalnet.bots.GenericBot._init_database">
|
||||
<code class="descname">_init_database</code><span class="sig-paren">(</span><em>commands: List[Type[royalnet.utils.command.Command]], database_config: royalnet.database.databaseconfig.DatabaseConfig</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.bots.GenericBot._init_database" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Create an <code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.Alchemy</span></code> with the tables required by the commands. Then, find the chain that links the <code class="docutils literal notranslate"><span class="pre">master_table</span></code> to the <code class="docutils literal notranslate"><span class="pre">identity_table</span></code>.</p>
|
||||
<dd><p>Create an <a class="reference internal" href="database.html#royalnet.database.Alchemy" title="royalnet.database.Alchemy"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.database.Alchemy</span></code></a> with the tables required by the commands. Then, find the chain that links the <code class="docutils literal notranslate"><span class="pre">master_table</span></code> to the <code class="docutils literal notranslate"><span class="pre">identity_table</span></code>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
|
@ -299,7 +314,12 @@
|
|||
<dl class="method">
|
||||
<dt id="royalnet.bots.GenericBot._network_handler">
|
||||
<code class="descname">_network_handler</code><span class="sig-paren">(</span><em>message: royalnet.network.messages.Message</em><span class="sig-paren">)</span> → royalnet.network.messages.Message<a class="headerlink" href="#royalnet.bots.GenericBot._network_handler" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Handle a single <a class="reference internal" href="network.html#royalnet.network.Message" title="royalnet.network.Message"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.Message</span></code></a> received from the <a class="reference internal" href="network.html#royalnet.network.RoyalnetLink" title="royalnet.network.RoyalnetLink"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.RoyalnetLink</span></code></a></p>
|
||||
<dd><p>Handle a single <a class="reference internal" href="network.html#royalnet.network.Message" title="royalnet.network.Message"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.Message</span></code></a> received from the <a class="reference internal" href="network.html#royalnet.network.RoyalnetLink" title="royalnet.network.RoyalnetLink"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.RoyalnetLink</span></code></a>.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Returns</dt>
|
||||
<dd class="field-odd"><p>Another message, to be sent as <a class="reference internal" href="network.html#royalnet.network.Reply" title="royalnet.network.Reply"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.Reply</span></code></a>.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
|
|
|
@ -257,6 +257,11 @@
|
|||
<em class="property">class </em><code class="descclassname">royalnet.commands.</code><code class="descname">PlaymodeCommand</code><a class="headerlink" href="#royalnet.commands.PlaymodeCommand" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="royalnet.commands.VideochannelCommand">
|
||||
<em class="property">class </em><code class="descclassname">royalnet.commands.</code><code class="descname">VideochannelCommand</code><a class="headerlink" href="#royalnet.commands.VideochannelCommand" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
@ -259,7 +259,7 @@
|
|||
|
||||
<dl class="attribute">
|
||||
<dt id="royalnet.database.tables.Telegram.royal">
|
||||
<code class="descname">royal</code><em class="property"> = <RelationshipProperty at 0x7a70300; no key></em><a class="headerlink" href="#royalnet.database.tables.Telegram.royal" title="Permalink to this definition">¶</a></dt>
|
||||
<code class="descname">royal</code><em class="property"> = <RelationshipProperty at 0x73b84b0; no key></em><a class="headerlink" href="#royalnet.database.tables.Telegram.royal" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="attribute">
|
||||
|
@ -289,7 +289,7 @@
|
|||
|
||||
<dl class="attribute">
|
||||
<dt id="royalnet.database.tables.Diario.creator">
|
||||
<code class="descname">creator</code><em class="property"> = <RelationshipProperty at 0x7a70348; no key></em><a class="headerlink" href="#royalnet.database.tables.Diario.creator" title="Permalink to this definition">¶</a></dt>
|
||||
<code class="descname">creator</code><em class="property"> = <RelationshipProperty at 0x73b84f8; no key></em><a class="headerlink" href="#royalnet.database.tables.Diario.creator" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="attribute">
|
||||
|
@ -314,7 +314,7 @@
|
|||
|
||||
<dl class="attribute">
|
||||
<dt id="royalnet.database.tables.Diario.quoted_account">
|
||||
<code class="descname">quoted_account</code><em class="property"> = <RelationshipProperty at 0x7a70978; no key></em><a class="headerlink" href="#royalnet.database.tables.Diario.quoted_account" title="Permalink to this definition">¶</a></dt>
|
||||
<code class="descname">quoted_account</code><em class="property"> = <RelationshipProperty at 0x73b8b28; no key></em><a class="headerlink" href="#royalnet.database.tables.Diario.quoted_account" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="attribute">
|
||||
|
@ -349,7 +349,7 @@
|
|||
|
||||
<dl class="attribute">
|
||||
<dt id="royalnet.database.tables.Alias.royal">
|
||||
<code class="descname">royal</code><em class="property"> = <RelationshipProperty at 0x7a70198; no key></em><a class="headerlink" href="#royalnet.database.tables.Alias.royal" title="Permalink to this definition">¶</a></dt>
|
||||
<code class="descname">royal</code><em class="property"> = <RelationshipProperty at 0x73b8198; no key></em><a class="headerlink" href="#royalnet.database.tables.Alias.royal" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="attribute">
|
||||
|
@ -364,7 +364,7 @@
|
|||
<em class="property">class </em><code class="descclassname">royalnet.database.tables.</code><code class="descname">ActiveKvGroup</code><a class="headerlink" href="#royalnet.database.tables.ActiveKvGroup" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><dl class="attribute">
|
||||
<dt id="royalnet.database.tables.ActiveKvGroup.group">
|
||||
<code class="descname">group</code><em class="property"> = <RelationshipProperty at 0x7a701e0; no key></em><a class="headerlink" href="#royalnet.database.tables.ActiveKvGroup.group" title="Permalink to this definition">¶</a></dt>
|
||||
<code class="descname">group</code><em class="property"> = <RelationshipProperty at 0x73b80c0; no key></em><a class="headerlink" href="#royalnet.database.tables.ActiveKvGroup.group" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="attribute">
|
||||
|
@ -374,7 +374,7 @@
|
|||
|
||||
<dl class="attribute">
|
||||
<dt id="royalnet.database.tables.ActiveKvGroup.royal">
|
||||
<code class="descname">royal</code><em class="property"> = <RelationshipProperty at 0x7a70b70; no key></em><a class="headerlink" href="#royalnet.database.tables.ActiveKvGroup.royal" title="Permalink to this definition">¶</a></dt>
|
||||
<code class="descname">royal</code><em class="property"> = <RelationshipProperty at 0x73b8df8; no key></em><a class="headerlink" href="#royalnet.database.tables.ActiveKvGroup.royal" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="attribute">
|
||||
|
@ -389,7 +389,7 @@
|
|||
<em class="property">class </em><code class="descclassname">royalnet.database.tables.</code><code class="descname">Keyvalue</code><a class="headerlink" href="#royalnet.database.tables.Keyvalue" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><dl class="attribute">
|
||||
<dt id="royalnet.database.tables.Keyvalue.group">
|
||||
<code class="descname">group</code><em class="property"> = <RelationshipProperty at 0x7a709c0; no key></em><a class="headerlink" href="#royalnet.database.tables.Keyvalue.group" title="Permalink to this definition">¶</a></dt>
|
||||
<code class="descname">group</code><em class="property"> = <RelationshipProperty at 0x73b8930; no key></em><a class="headerlink" href="#royalnet.database.tables.Keyvalue.group" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="attribute">
|
||||
|
@ -444,7 +444,7 @@
|
|||
|
||||
<dl class="attribute">
|
||||
<dt id="royalnet.database.tables.Discord.royal">
|
||||
<code class="descname">royal</code><em class="property"> = <RelationshipProperty at 0x7a70a08; no key></em><a class="headerlink" href="#royalnet.database.tables.Discord.royal" title="Permalink to this definition">¶</a></dt>
|
||||
<code class="descname">royal</code><em class="property"> = <RelationshipProperty at 0x73b8b28; no key></em><a class="headerlink" href="#royalnet.database.tables.Discord.royal" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="attribute">
|
||||
|
|
|
@ -786,6 +786,8 @@
|
|||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="database.html#royalnet.database.tables.Keyvalue.value">value (royalnet.database.tables.Keyvalue attribute)</a>
|
||||
</li>
|
||||
<li><a href="commands.html#royalnet.commands.VideochannelCommand">VideochannelCommand (class in royalnet.commands)</a>
|
||||
</li>
|
||||
<li><a href="commands.html#royalnet.commands.VideoinfoCommand">VideoinfoCommand (class in royalnet.commands)</a>
|
||||
</li>
|
||||
|
|
|
@ -237,7 +237,8 @@
|
|||
<dl class="exception">
|
||||
<dt id="royalnet.network.NotIdentifiedError">
|
||||
<em class="property">exception </em><code class="descclassname">royalnet.network.</code><code class="descname">NotIdentifiedError</code><a class="headerlink" href="#royalnet.network.NotIdentifiedError" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
<dd><p>The <a class="reference internal" href="#royalnet.network.RoyalnetLink" title="royalnet.network.RoyalnetLink"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.RoyalnetLink</span></code></a> has not identified yet to a <a class="reference internal" href="#royalnet.network.RoyalnetServer" title="royalnet.network.RoyalnetServer"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.network.RoyalnetServer</span></code></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="royalnet.network.Package">
|
||||
|
|
Binary file not shown.
File diff suppressed because one or more lines are too long
|
@ -277,18 +277,32 @@ The data must be pickleable.</p>
|
|||
|
||||
<dl class="function">
|
||||
<dt id="royalnet.utils.sleep_until">
|
||||
<code class="descclassname">royalnet.utils.</code><code class="descname">sleep_until</code><span class="sig-paren">(</span><em>dt: datetime.datetime</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.utils.sleep_until" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
<code class="descclassname">royalnet.utils.</code><code class="descname">sleep_until</code><span class="sig-paren">(</span><em>dt: datetime.datetime</em><span class="sig-paren">)</span> → None<a class="headerlink" href="#royalnet.utils.sleep_until" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Block the call until the specified datetime.</p>
|
||||
<div class="admonition warning">
|
||||
<p class="admonition-title">Warning</p>
|
||||
<p>Accurate only to seconds.</p>
|
||||
</div>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="royalnet.utils.plusformat">
|
||||
<code class="descclassname">royalnet.utils.</code><code class="descname">plusformat</code><span class="sig-paren">(</span><em>i: int</em><span class="sig-paren">)</span> → str<a class="headerlink" href="#royalnet.utils.plusformat" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
<dd><p>Convert an <a class="reference external" href="https://docs.python.org/3.7/library/functions.html#int" title="(in Python v3.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a> to a string, adding a plus if they are greater than 0.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters</dt>
|
||||
<dd class="field-odd"><p><strong>i</strong> – the <a class="reference external" href="https://docs.python.org/3.7/library/functions.html#int" title="(in Python v3.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a> to convert</p>
|
||||
</dd>
|
||||
<dt class="field-even">Returns</dt>
|
||||
<dd class="field-even"><p>The resulting <a class="reference external" href="https://docs.python.org/3.7/library/stdtypes.html#str" title="(in Python v3.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a></p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="royalnet.utils.CommandArgs">
|
||||
<em class="property">class </em><code class="descclassname">royalnet.utils.</code><code class="descname">CommandArgs</code><a class="headerlink" href="#royalnet.utils.CommandArgs" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>The arguments of a command. Raises InvalidInputError if the requested argument does not exist.</p>
|
||||
<dd><p>The arguments of a command. Raises <code class="xref py py-exc docutils literal notranslate"><span class="pre">InvalidInputError</span></code> if the requested argument does not exist.</p>
|
||||
<dl class="method">
|
||||
<dt id="royalnet.utils.CommandArgs.joined">
|
||||
<code class="descname">joined</code><span class="sig-paren">(</span><em>*</em>, <em>require_at_least=0</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.utils.CommandArgs.joined" title="Permalink to this definition">¶</a></dt>
|
||||
|
@ -320,7 +334,8 @@ The data must be pickleable.</p>
|
|||
<dl class="function">
|
||||
<dt id="royalnet.utils.safefilename">
|
||||
<code class="descclassname">royalnet.utils.</code><code class="descname">safefilename</code><span class="sig-paren">(</span><em>string: str</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.utils.safefilename" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
<dd><p>Ensure a string can be used as a filename by replacing all non-word characters with underscores.</p>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
from . import audio, bots, commands, database, network, utils
|
||||
from . import audio, bots, commands, database, network, utils, error
|
||||
|
||||
__all__ = ["audio", "bots", "commands", "database", "network", "utils"]
|
||||
__all__ = ["audio", "bots", "commands", "database", "network", "utils", "error"]
|
||||
|
|
|
@ -17,7 +17,7 @@ class NotConnectedError(Exception):
|
|||
|
||||
|
||||
class NotIdentifiedError(Exception):
|
||||
pass
|
||||
"""The :py:class:`royalnet.network.RoyalnetLink` has not identified yet to a :py:class:`royalnet.network.RoyalnetServer`."""
|
||||
|
||||
|
||||
class NetworkError(Exception):
|
||||
|
|
|
@ -4,7 +4,7 @@ from royalnet.error import InvalidInputError
|
|||
|
||||
|
||||
class CommandArgs(list):
|
||||
"""The arguments of a command. Raises InvalidInputError if the requested argument does not exist."""
|
||||
"""The arguments of a command. Raises :py:exc:`InvalidInputError` if the requested argument does not exist."""
|
||||
|
||||
def __getitem__(self, item):
|
||||
if isinstance(item, int):
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
def plusformat(i: int) -> str:
|
||||
"""Convert an :py:class:`int` to a string, adding a plus if they are greater than 0.
|
||||
|
||||
Parameters:
|
||||
i: the :py:class:`int` to convert
|
||||
|
||||
Returns:
|
||||
The resulting :py:class:`str`"""
|
||||
if i >= 0:
|
||||
return f"+{i}"
|
||||
return str(i)
|
||||
|
|
|
@ -2,4 +2,5 @@ import re
|
|||
|
||||
|
||||
def safefilename(string: str):
|
||||
"""Ensure a string can be used as a filename by replacing all non-word characters with underscores."""
|
||||
return re.sub(r"\W", "_", string)
|
||||
|
|
|
@ -2,7 +2,11 @@ import asyncio
|
|||
import datetime
|
||||
|
||||
|
||||
async def sleep_until(dt: datetime.datetime):
|
||||
async def sleep_until(dt: datetime.datetime) -> None:
|
||||
"""Block the call until the specified datetime.
|
||||
|
||||
Warning:
|
||||
Accurate only to seconds."""
|
||||
now = datetime.datetime.now()
|
||||
if now > dt:
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue