Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
v1.0.7-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevo committed Jul 30, 2021
1 parent 34c73be commit 557b4d3
Show file tree
Hide file tree
Showing 43 changed files with 16,132 additions and 4,981 deletions.
4 changes: 2 additions & 2 deletions compile_everything.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
cd "$(dirname "$0")"

compile_documentation.sh
compile_for_pypi.sh
bash ./compile_documentation.sh
bash ./compile_for_pypi.sh
18 changes: 9 additions & 9 deletions documentation/docs/custom_types.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h3 id="types">Types:</h3>
<details class="source">
<summary>
<span>Expand source code</span>
<a href="https://github.com/CWKevo/pyFlarum/blob/7ed27a36b4f20b9e15306719e4baae207ebb9ced/pyflarum\custom_types.py#L0-L19" class="git-link">Browse git</a>
<a href="https://github.com/CWKevo/pyFlarum/blob/34c73be471b00e6f8db85df51c6e50b367d3b656/pyflarum\custom_types.py#L0-L19" class="git-link">Browse git</a>
</summary>
<pre><code class="python">&#34;&#34;&#34;
Custom types for pyFlarum.
Expand All @@ -43,17 +43,17 @@ <h3 id="types">Types:</h3>
- `AnyPost` - `Post`, `PostFromBulk`, `PostFromNotification`
&#34;&#34;&#34;

from typing import Union
from typing import Union, TYPE_CHECKING


from .flarum.core.users import User, UserFromBulk, UserFromNotification
from .flarum.core.discussions import Discussion, DiscussionFromBulk, DiscussionFromNotification
from .flarum.core.posts import Post, PostFromBulk, PostFromNotification
if TYPE_CHECKING:
from .flarum.core.users import User, UserFromBulk, UserFromNotification
from .flarum.core.discussions import Discussion, DiscussionFromBulk, DiscussionFromNotification
from .flarum.core.posts import Post, PostFromBulk, PostFromNotification, PostFromDiscussion


AnyUser = Union[User, UserFromBulk, UserFromNotification]
AnyDiscussion = Union[Discussion, DiscussionFromBulk, DiscussionFromNotification]
AnyPost = Union[Post, PostFromBulk, PostFromNotification]</code></pre>
AnyUser = Union[User, UserFromBulk, UserFromNotification]
AnyDiscussion = Union[Discussion, DiscussionFromBulk, DiscussionFromNotification]
AnyPost = Union[Post, PostFromBulk, PostFromNotification, PostFromDiscussion]</code></pre>
</details>
</section>
<section>
Expand Down
6 changes: 3 additions & 3 deletions documentation/docs/datetime_conversions.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h1 class="title">Module <code>pyflarum.datetime_conversions</code></h1>
<details class="source">
<summary>
<span>Expand source code</span>
<a href="https://github.com/CWKevo/pyFlarum/blob/7ed27a36b4f20b9e15306719e4baae207ebb9ced/pyflarum\datetime_conversions.py#L0-L42" class="git-link">Browse git</a>
<a href="https://github.com/CWKevo/pyFlarum/blob/34c73be471b00e6f8db85df51c6e50b367d3b656/pyflarum\datetime_conversions.py#L0-L42" class="git-link">Browse git</a>
</summary>
<pre><code class="python">from typing import Optional, Union

Expand Down Expand Up @@ -89,7 +89,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
<details class="source">
<summary>
<span>Expand source code</span>
<a href="https://github.com/CWKevo/pyFlarum/blob/7ed27a36b4f20b9e15306719e4baae207ebb9ced/pyflarum\datetime_conversions.py#L26-L43" class="git-link">Browse git</a>
<a href="https://github.com/CWKevo/pyFlarum/blob/34c73be471b00e6f8db85df51c6e50b367d3b656/pyflarum\datetime_conversions.py#L26-L43" class="git-link">Browse git</a>
</summary>
<pre><code class="python">def datetime_to_flarum(dt: Optional[Union[datetime, str]]=None):
&#34;&#34;&#34;
Expand Down Expand Up @@ -121,7 +121,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
<details class="source">
<summary>
<span>Expand source code</span>
<a href="https://github.com/CWKevo/pyFlarum/blob/7ed27a36b4f20b9e15306719e4baae207ebb9ced/pyflarum\datetime_conversions.py#L6-L23" class="git-link">Browse git</a>
<a href="https://github.com/CWKevo/pyFlarum/blob/34c73be471b00e6f8db85df51c6e50b367d3b656/pyflarum\datetime_conversions.py#L6-L23" class="git-link">Browse git</a>
</summary>
<pre><code class="python">def flarum_to_datetime(flarum_dt: Optional[Union[str, datetime]]=None):
&#34;&#34;&#34;
Expand Down
82 changes: 51 additions & 31 deletions documentation/docs/error_handler.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ <h1 class="title">Module <code>pyflarum.error_handler</code></h1>
<details class="source">
<summary>
<span>Expand source code</span>
<a href="https://github.com/CWKevo/pyFlarum/blob/7ed27a36b4f20b9e15306719e4baae207ebb9ced/pyflarum\error_handler.py#L0-L95" class="git-link">Browse git</a>
<a href="https://github.com/CWKevo/pyFlarum/blob/34c73be471b00e6f8db85df51c6e50b367d3b656/pyflarum\error_handler.py#L0-L105" class="git-link">Browse git</a>
</summary>
<pre><code class="python">from typing import Optional, List, Dict, TYPE_CHECKING
<pre><code class="python">from typing import Literal, NoReturn, Optional, List, Dict, TYPE_CHECKING, Union
if TYPE_CHECKING:
from requests.models import Response

from json.decoder import JSONDecodeError



class FlarumError(Exception):
&#34;&#34;&#34;
Generic class for all Flarum related errors.
Expand All @@ -57,11 +58,20 @@ <h1 class="title">Module <code>pyflarum.error_handler</code></h1>
pass


def parse_request(request: &#39;Response&#39;):

def parse_request(response: &#39;Response&#39;) -&gt; dict:
&#34;&#34;&#34;
Parses the request as JSON, raises `FlarumError` if
something went wrong.
&#34;&#34;&#34;

if not 200 &lt;= response.status_code &lt;= 204:
return handle_errors(status_code=response.status_code)

try:
# Includes opening and closing brackets:
if len(request.text) &gt;= 2:
json = request.json() # type: dict
if len(response.text) &gt;= 2:
json = response.json() # type: dict

else:
json = {}
Expand All @@ -71,18 +81,16 @@ <h1 class="title">Module <code>pyflarum.error_handler</code></h1>


if &#39;errors&#39; in json:
return handle_errors(json[&#39;errors&#39;])

elif not 200 &lt;= request.status_code &lt;= 204:
return handle_errors(status_code=request.status_code)
return handle_errors(errors=json[&#39;errors&#39;])


return json


def handle_errors(errors: Optional[List[Dict[str, str]]]=None, status_code: Optional[str]=None):
def handle_errors(errors: Optional[List[Dict[str, str]]]=None, status_code: Optional[str]=None) -&gt; Union[Literal[True], NoReturn]:
&#34;&#34;&#34;
Handles Flarum &amp; request related errors. Should be called on error only.
Handles Flarum &amp; request related errors.
Returns `FlarumError` if an error was found, `True` otherwise.
&#34;&#34;&#34;

if errors:
Expand Down Expand Up @@ -122,7 +130,9 @@ <h1 class="title">Module <code>pyflarum.error_handler</code></h1>
raise FlarumError(f&#39;Error {status}: {code} - {details}&#39;, status=status, code=code, details=details)

else:
raise FlarumError(f&#39;Request related error: {status_code}&#39;)</code></pre>
raise FlarumError(f&#39;Request related error: {status_code} (https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/{status_code})&#39;)

return True</code></pre>
</details>
</section>
<section>
Expand All @@ -133,18 +143,20 @@ <h1 class="title">Module <code>pyflarum.error_handler</code></h1>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="pyflarum.error_handler.handle_errors"><code class="name flex">
<span>def <span class="ident">handle_errors</span></span>(<span>errors: Optional[List[Dict[str, str]]] = None, status_code: Optional[str] = None)</span>
<span>def <span class="ident">handle_errors</span></span>(<span>errors: Optional[List[Dict[str, str]]] = None, status_code: Optional[str] = None)> Union[Literal[True], NoReturn]</span>
</code></dt>
<dd>
<div class="desc"><p>Handles Flarum &amp; request related errors. Should be called on error only.</p></div>
<div class="desc"><p>Handles Flarum &amp; request related errors.
Returns <code><a title="pyflarum.error_handler.FlarumError" href="#pyflarum.error_handler.FlarumError">FlarumError</a></code> if an error was found, <code>True</code> otherwise.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
<a href="https://github.com/CWKevo/pyFlarum/blob/7ed27a36b4f20b9e15306719e4baae207ebb9ced/pyflarum\error_handler.py#L54-L96" class="git-link">Browse git</a>
<a href="https://github.com/CWKevo/pyFlarum/blob/34c73be471b00e6f8db85df51c6e50b367d3b656/pyflarum\error_handler.py#L61-L106" class="git-link">Browse git</a>
</summary>
<pre><code class="python">def handle_errors(errors: Optional[List[Dict[str, str]]]=None, status_code: Optional[str]=None):
<pre><code class="python">def handle_errors(errors: Optional[List[Dict[str, str]]]=None, status_code: Optional[str]=None) -&gt; Union[Literal[True], NoReturn]:
&#34;&#34;&#34;
Handles Flarum &amp; request related errors. Should be called on error only.
Handles Flarum &amp; request related errors.
Returns `FlarumError` if an error was found, `True` otherwise.
&#34;&#34;&#34;

if errors:
Expand Down Expand Up @@ -184,24 +196,35 @@ <h2 class="section-title" id="header-functions">Functions</h2>
raise FlarumError(f&#39;Error {status}: {code} - {details}&#39;, status=status, code=code, details=details)

else:
raise FlarumError(f&#39;Request related error: {status_code}&#39;)</code></pre>
raise FlarumError(f&#39;Request related error: {status_code} (https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/{status_code})&#39;)

return True</code></pre>
</details>
</dd>
<dt id="pyflarum.error_handler.parse_request"><code class="name flex">
<span>def <span class="ident">parse_request</span></span>(<span>request: Response)</span>
<span>def <span class="ident">parse_request</span></span>(<span>response: Response)> dict</span>
</code></dt>
<dd>
<div class="desc"></div>
<div class="desc"><p>Parses the request as JSON, raises <code><a title="pyflarum.error_handler.FlarumError" href="#pyflarum.error_handler.FlarumError">FlarumError</a></code> if
something went wrong.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
<a href="https://github.com/CWKevo/pyFlarum/blob/7ed27a36b4f20b9e15306719e4baae207ebb9ced/pyflarum\error_handler.py#L31-L51" class="git-link">Browse git</a>
<a href="https://github.com/CWKevo/pyFlarum/blob/34c73be471b00e6f8db85df51c6e50b367d3b656/pyflarum\error_handler.py#L33-L58" class="git-link">Browse git</a>
</summary>
<pre><code class="python">def parse_request(request: &#39;Response&#39;):
<pre><code class="python">def parse_request(response: &#39;Response&#39;) -&gt; dict:
&#34;&#34;&#34;
Parses the request as JSON, raises `FlarumError` if
something went wrong.
&#34;&#34;&#34;

if not 200 &lt;= response.status_code &lt;= 204:
return handle_errors(status_code=response.status_code)

try:
# Includes opening and closing brackets:
if len(request.text) &gt;= 2:
json = request.json() # type: dict
if len(response.text) &gt;= 2:
json = response.json() # type: dict

else:
json = {}
Expand All @@ -211,10 +234,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>


if &#39;errors&#39; in json:
return handle_errors(json[&#39;errors&#39;])

elif not 200 &lt;= request.status_code &lt;= 204:
return handle_errors(status_code=request.status_code)
return handle_errors(errors=json[&#39;errors&#39;])


return json</code></pre>
Expand All @@ -234,7 +254,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
<details class="source">
<summary>
<span>Expand source code</span>
<a href="https://github.com/CWKevo/pyFlarum/blob/7ed27a36b4f20b9e15306719e4baae207ebb9ced/pyflarum\error_handler.py#L8-L18" class="git-link">Browse git</a>
<a href="https://github.com/CWKevo/pyFlarum/blob/34c73be471b00e6f8db85df51c6e50b367d3b656/pyflarum\error_handler.py#L9-L19" class="git-link">Browse git</a>
</summary>
<pre><code class="python">class FlarumError(Exception):
&#34;&#34;&#34;
Expand Down Expand Up @@ -263,7 +283,7 @@ <h3>Ancestors</h3>
<details class="source">
<summary>
<span>Expand source code</span>
<a href="https://github.com/CWKevo/pyFlarum/blob/7ed27a36b4f20b9e15306719e4baae207ebb9ced/pyflarum\error_handler.py#L21-L23" class="git-link">Browse git</a>
<a href="https://github.com/CWKevo/pyFlarum/blob/34c73be471b00e6f8db85df51c6e50b367d3b656/pyflarum\error_handler.py#L22-L24" class="git-link">Browse git</a>
</summary>
<pre><code class="python">class MissingExtensionError(Exception):
&#34;&#34;&#34;Missing pyFlarum extension error.&#34;&#34;&#34;
Expand All @@ -284,7 +304,7 @@ <h3>Ancestors</h3>
<details class="source">
<summary>
<span>Expand source code</span>
<a href="https://github.com/CWKevo/pyFlarum/blob/7ed27a36b4f20b9e15306719e4baae207ebb9ced/pyflarum\error_handler.py#L26-L28" class="git-link">Browse git</a>
<a href="https://github.com/CWKevo/pyFlarum/blob/34c73be471b00e6f8db85df51c6e50b367d3b656/pyflarum\error_handler.py#L27-L29" class="git-link">Browse git</a>
</summary>
<pre><code class="python">class MissingExtensionWarning(Warning):
&#34;&#34;&#34;Missing pyFlarum extension warning.&#34;&#34;&#34;
Expand Down
Loading

0 comments on commit 557b4d3

Please sign in to comment.