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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: aioe621
3
- Version: 0.2.0
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 ![uv](https://img.shields.io/badge/uv-261230.svg?logo=uv&logoColor=#de5fe9)
46
+
47
+ ![PyPI Python Version](https://img.shields.io/pypi/pyversions/aioe621)
48
+
49
+ ![GitHub License](https://img.shields.io/github/license/penggrin12/aioe621)
50
+ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/penggrin12/aioe621/release.yml)
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`
@@ -0,0 +1,42 @@
1
+ # aioe621 ![uv](https://img.shields.io/badge/uv-261230.svg?logo=uv&logoColor=#de5fe9)
2
+
3
+ ![PyPI Python Version](https://img.shields.io/pypi/pyversions/aioe621)
4
+
5
+ ![GitHub License](https://img.shields.io/github/license/penggrin12/aioe621)
6
+ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/penggrin12/aioe621/release.yml)
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.0"
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
  ]
@@ -0,0 +1,11 @@
1
+ from aioe621 import client, exceptions, schemas
2
+ from aioe621.client import Client
3
+ from aioe621.schemas import Auth
4
+
5
+ __all__: tuple[str, ...] = (
6
+ "client",
7
+ "exceptions",
8
+ "schemas",
9
+ "Client",
10
+ "Auth",
11
+ )
@@ -3,11 +3,14 @@
3
3
  import httpx
4
4
  from pydantic import BaseModel
5
5
 
6
- from aioe621.exceptions import AccessDeniedError
7
-
8
- from .endpoints.posts import Posts
9
- from .exceptions import APIError, AuthenticationError, NotFoundError
10
- from .schemas import _ErrorResponse
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}
@@ -0,0 +1,3 @@
1
+ from .posts import Posts
2
+
3
+ __all__: tuple[str, ...] = ("Posts",)
@@ -1,7 +1,7 @@
1
1
  import typing
2
2
 
3
3
  if typing.TYPE_CHECKING:
4
- from ..client import Client
4
+ from aioe621.client import Client
5
5
 
6
6
 
7
7
  class Endpoint:
@@ -1,15 +1,17 @@
1
- from ..schemas import Post, _PostsListResponse, _PostsOnePostResponse
2
- from .endpoint import Endpoint
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: list[str] | str,
10
+ tags: Iterable[str] | str,
9
11
  limit: int | None = None,
10
12
  page: int | None = None,
11
- ) -> list[Post]:
12
- if isinstance(tags, list):
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 httpx
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: httpx.Response) -> None:
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: httpx.Response) -> None:
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: httpx.Response) -> None:
44
+ def __init__(self, response: "Response") -> None:
34
45
  super().__init__("Access denied.", response)
@@ -1,4 +0,0 @@
1
- from .client import Client
2
- from .schemas import Auth
3
-
4
- __all__ = ["Client", "Auth"]
File without changes
File without changes
File without changes
File without changes