aioe621 0.2.0__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {aioe621-0.2.0 → aioe621-0.2.2}/PKG-INFO +45 -1
- aioe621-0.2.2/README.md +42 -0
- {aioe621-0.2.0 → aioe621-0.2.2}/pyproject.toml +3 -1
- aioe621-0.2.2/src/aioe621/__init__.py +11 -0
- {aioe621-0.2.0 → aioe621-0.2.2}/src/aioe621/client.py +9 -6
- aioe621-0.2.2/src/aioe621/endpoints/__init__.py +3 -0
- {aioe621-0.2.0 → aioe621-0.2.2}/src/aioe621/endpoints/endpoint.py +1 -1
- {aioe621-0.2.0 → aioe621-0.2.2}/src/aioe621/endpoints/posts.py +9 -5
- {aioe621-0.2.0 → aioe621-0.2.2}/src/aioe621/exceptions.py +15 -4
- aioe621-0.2.0/src/aioe621/__init__.py +0 -4
- aioe621-0.2.0/src/aioe621/endpoints/__init__.py +0 -0
- {aioe621-0.2.0 → aioe621-0.2.2}/LICENSE +0 -0
- {aioe621-0.2.0 → aioe621-0.2.2}/src/aioe621/py.typed +0 -0
- {aioe621-0.2.0 → aioe621-0.2.2}/src/aioe621/schemas.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: aioe621
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: A simple asynchronous httpx+pydantic wrapper over the E621's API
|
|
5
5
|
Keywords: async,httpx,e621
|
|
6
6
|
Author: penggrin12
|
|
@@ -40,3 +40,47 @@ Requires-Dist: httpx>=0.28.1
|
|
|
40
40
|
Requires-Dist: pydantic>=2.13.4
|
|
41
41
|
Requires-Python: >=3.10
|
|
42
42
|
Project-URL: Homepage, https://github.com/penggrin12/aioe621
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
|
|
45
|
+
# aioe621 
|
|
46
|
+
|
|
47
|
+

|
|
48
|
+
|
|
49
|
+

|
|
50
|
+

|
|
51
|
+
|
|
52
|
+
A simple asynchronous httpx+pydantic wrapper over the E621's API
|
|
53
|
+
|
|
54
|
+
## Quickstart
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from aioe621 import Client, Auth
|
|
58
|
+
from aioe621.schemas import Post
|
|
59
|
+
import asyncio
|
|
60
|
+
|
|
61
|
+
# authentication is only needed for some endpoints
|
|
62
|
+
auth = Auth(
|
|
63
|
+
username="hexerade",
|
|
64
|
+
api_key="1nHrmzmsvJf26EhU1F7CjnjC",
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
# all other Client parameters are also optional
|
|
68
|
+
client = Client(
|
|
69
|
+
auth=auth,
|
|
70
|
+
user_agent="MyProject/1.0 (by username on e621)"
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
async def main() -> None:
|
|
75
|
+
post: Post = await client.posts.get(id=5937863)
|
|
76
|
+
print(f"i love {post.tags.artist[0]}!!!")
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
asyncio.run(main())
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Currently implemented
|
|
83
|
+
|
|
84
|
+
- [x] `GET /posts.json` via `.posts.list`
|
|
85
|
+
- [x] `GET /posts/{id}.json` via `.posts.get`
|
|
86
|
+
- [x] `GET /posts/random.json` via `.posts.random`
|
aioe621-0.2.2/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# aioe621 
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
A simple asynchronous httpx+pydantic wrapper over the E621's API
|
|
9
|
+
|
|
10
|
+
## Quickstart
|
|
11
|
+
|
|
12
|
+
```python
|
|
13
|
+
from aioe621 import Client, Auth
|
|
14
|
+
from aioe621.schemas import Post
|
|
15
|
+
import asyncio
|
|
16
|
+
|
|
17
|
+
# authentication is only needed for some endpoints
|
|
18
|
+
auth = Auth(
|
|
19
|
+
username="hexerade",
|
|
20
|
+
api_key="1nHrmzmsvJf26EhU1F7CjnjC",
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
# all other Client parameters are also optional
|
|
24
|
+
client = Client(
|
|
25
|
+
auth=auth,
|
|
26
|
+
user_agent="MyProject/1.0 (by username on e621)"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
async def main() -> None:
|
|
31
|
+
post: Post = await client.posts.get(id=5937863)
|
|
32
|
+
print(f"i love {post.tags.artist[0]}!!!")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
asyncio.run(main())
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Currently implemented
|
|
39
|
+
|
|
40
|
+
- [x] `GET /posts.json` via `.posts.list`
|
|
41
|
+
- [x] `GET /posts/{id}.json` via `.posts.get`
|
|
42
|
+
- [x] `GET /posts/random.json` via `.posts.random`
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "aioe621"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.2"
|
|
4
4
|
description = "A simple asynchronous httpx+pydantic wrapper over the E621's API"
|
|
5
5
|
license = { file = "LICENSE" }
|
|
6
|
+
readme = "README.md"
|
|
6
7
|
keywords = ["async", "httpx", "e621"]
|
|
7
8
|
authors = [
|
|
8
9
|
{ name = "penggrin12", email = "miner.sidor@gmail.com" }
|
|
@@ -35,4 +36,5 @@ build-backend = "uv_build"
|
|
|
35
36
|
dev = [
|
|
36
37
|
"ruff>=0.15.21",
|
|
37
38
|
"pyrefly>=0.60.0",
|
|
39
|
+
"respx>=0.23.1",
|
|
38
40
|
]
|
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
import httpx
|
|
4
4
|
from pydantic import BaseModel
|
|
5
5
|
|
|
6
|
-
from aioe621
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
from aioe621 import endpoints
|
|
7
|
+
from aioe621.exceptions import (
|
|
8
|
+
AccessDeniedError,
|
|
9
|
+
APIError,
|
|
10
|
+
AuthenticationError,
|
|
11
|
+
NotFoundError,
|
|
12
|
+
)
|
|
13
|
+
from aioe621.schemas import _ErrorResponse
|
|
11
14
|
|
|
12
15
|
if typing.TYPE_CHECKING:
|
|
13
16
|
from .schemas import Auth
|
|
@@ -35,7 +38,7 @@ class Client:
|
|
|
35
38
|
**session_kwargs,
|
|
36
39
|
)
|
|
37
40
|
|
|
38
|
-
self.posts = Posts(self)
|
|
41
|
+
self.posts = endpoints.Posts(self)
|
|
39
42
|
|
|
40
43
|
def _get_headers(self) -> dict[str, str]:
|
|
41
44
|
return {"User-Agent": self.user_agent}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
from
|
|
2
|
-
|
|
1
|
+
from typing import Iterable
|
|
2
|
+
|
|
3
|
+
from aioe621.endpoints.endpoint import Endpoint
|
|
4
|
+
from aioe621.schemas import Post, _PostsListResponse, _PostsOnePostResponse
|
|
3
5
|
|
|
4
6
|
|
|
5
7
|
class Posts(Endpoint):
|
|
6
8
|
async def list(
|
|
7
9
|
self,
|
|
8
|
-
tags:
|
|
10
|
+
tags: Iterable[str] | str,
|
|
9
11
|
limit: int | None = None,
|
|
10
12
|
page: int | None = None,
|
|
11
|
-
) ->
|
|
12
|
-
if isinstance(tags,
|
|
13
|
+
) -> tuple[Post, ...]:
|
|
14
|
+
if not isinstance(tags, str):
|
|
13
15
|
tags = " ".join(tags)
|
|
14
16
|
|
|
15
17
|
return (
|
|
@@ -23,6 +25,8 @@ class Posts(Endpoint):
|
|
|
23
25
|
)
|
|
24
26
|
).posts
|
|
25
27
|
|
|
28
|
+
search = list
|
|
29
|
+
|
|
26
30
|
async def get(
|
|
27
31
|
self,
|
|
28
32
|
id: int,
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import typing
|
|
2
|
+
|
|
3
|
+
if typing.TYPE_CHECKING:
|
|
4
|
+
from httpx import Response
|
|
5
|
+
|
|
6
|
+
__all__: list[str] = [
|
|
7
|
+
"WrapperError",
|
|
8
|
+
"AuthenticationError",
|
|
9
|
+
"APIError",
|
|
10
|
+
"NotFoundError",
|
|
11
|
+
"AccessDeniedError",
|
|
12
|
+
]
|
|
2
13
|
|
|
3
14
|
|
|
4
15
|
class WrapperError(Exception):
|
|
@@ -16,7 +27,7 @@ class AuthenticationError(WrapperError):
|
|
|
16
27
|
|
|
17
28
|
|
|
18
29
|
class APIError(Exception):
|
|
19
|
-
def __init__(self, message: str, response:
|
|
30
|
+
def __init__(self, message: str, response: "Response") -> None:
|
|
20
31
|
self.method = response.request.method
|
|
21
32
|
self.url = response.request.url
|
|
22
33
|
super().__init__(
|
|
@@ -25,10 +36,10 @@ class APIError(Exception):
|
|
|
25
36
|
|
|
26
37
|
|
|
27
38
|
class NotFoundError(APIError):
|
|
28
|
-
def __init__(self, response:
|
|
39
|
+
def __init__(self, response: "Response") -> None:
|
|
29
40
|
super().__init__("Not found.", response)
|
|
30
41
|
|
|
31
42
|
|
|
32
43
|
class AccessDeniedError(APIError):
|
|
33
|
-
def __init__(self, response:
|
|
44
|
+
def __init__(self, response: "Response") -> None:
|
|
34
45
|
super().__init__("Access denied.", response)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|