quickspirit 1.0.5__tar.gz → 2.0.1__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: quickspirit
3
- Version: 1.0.5
3
+ Version: 2.0.1
4
4
  Summary: Fast, Async Network & File Downloader Client In Python
5
5
  Home-page: https://github.com/DroidZed/QuickSpirit-Async
6
6
  License: GPL-3.0-or-later
@@ -19,9 +19,7 @@ Classifier: Programming Language :: Python :: 3.10
19
19
  Classifier: Programming Language :: Python :: 3.11
20
20
  Classifier: Programming Language :: Python :: 3.12
21
21
  Classifier: Programming Language :: Python :: 3.13
22
- Provides-Extra: downloader
23
22
  Requires-Dist: aiofiles (>=24.1.0)
24
- Requires-Dist: aiofiles ; extra == "downloader"
25
23
  Requires-Dist: httpx (>=0.27.0)
26
24
  Project-URL: Repository, https://github.com/DroidZed/QuickSpirit-Async
27
25
  Description-Content-Type: text/markdown
@@ -52,6 +50,37 @@ poetry add quickspirit
52
50
  uv add quickspirit
53
51
  ```
54
52
 
53
+ ## Usage:
54
+
55
+ The library's getter function returns a bytes data repersenting the bytes coming in from the network. Since we don't know the shape of the data, I delegated the responsibility to you to figure out how to parse it to your liking.
56
+
57
+ A sample code would look like this:
58
+
59
+ ```py
60
+ from quickspirit import HttpAsyncClient
61
+ from asyncio import run
62
+ from json import joads
63
+ from typing import Any
64
+
65
+ async def main():
66
+ result = await HttpAsyncClient().get("https://some distant url returning json hopefully")
67
+
68
+ if result.Error:
69
+ raise result.Error
70
+
71
+
72
+ data: dict[str, Any] = loads(result.Data)
73
+
74
+ # do whatever you need now that you have the data...
75
+
76
+
77
+ if __name__ == "__main__":
78
+ run(main())
79
+
80
+ ```
81
+
82
+ A complete example can be found in the `example` directory.
83
+
55
84
  ## Testing:
56
85
 
57
86
  Clone with git:
@@ -0,0 +1,79 @@
1
+ # Quick Spirit
2
+
3
+ An easy to use HTTP client with a fast downloader.
4
+
5
+ This library was made with the famous [HTTPX](https://www.python-httpx.org/) library!
6
+
7
+ I originally intended to make a small module to refactor my networking layer in my apps using httpx, and ended up creating a library !
8
+
9
+ ----
10
+
11
+ ## Install
12
+
13
+ ```sh
14
+ # PIP:
15
+
16
+ pip install quickspirit
17
+
18
+ # Poetry:
19
+
20
+ poetry add quickspirit
21
+
22
+ # UV:
23
+
24
+ uv add quickspirit
25
+ ```
26
+
27
+ ## Usage:
28
+
29
+ The library's getter function returns a bytes data repersenting the bytes coming in from the network. Since we don't know the shape of the data, I delegated the responsibility to you to figure out how to parse it to your liking.
30
+
31
+ A sample code would look like this:
32
+
33
+ ```py
34
+ from quickspirit import HttpAsyncClient
35
+ from asyncio import run
36
+ from json import joads
37
+ from typing import Any
38
+
39
+ async def main():
40
+ result = await HttpAsyncClient().get("https://some distant url returning json hopefully")
41
+
42
+ if result.Error:
43
+ raise result.Error
44
+
45
+
46
+ data: dict[str, Any] = loads(result.Data)
47
+
48
+ # do whatever you need now that you have the data...
49
+
50
+
51
+ if __name__ == "__main__":
52
+ run(main())
53
+
54
+ ```
55
+
56
+ A complete example can be found in the `example` directory.
57
+
58
+ ## Testing:
59
+
60
+ Clone with git:
61
+
62
+ ```bash
63
+ git clone https://github.com/DroidZed/QuickSpirit-Async && cd QuickSpirit-Async
64
+ ```
65
+
66
+ Create a virtual env:
67
+
68
+ ```sh
69
+ python3 -m venv .venv && .venv/Scripts/activate
70
+ ```
71
+
72
+ Run the tests with pytest (install it first using your package manager of choice):
73
+
74
+ ```sh
75
+ # Here I'm using uv to run the tests, but the command should be the same for other package manager:
76
+
77
+ pytest -vs .
78
+ ```
79
+
@@ -1,8 +1,5 @@
1
1
  [tool.poetry]
2
- packages = [
3
- { include = "quick_spirit_http" },
4
- { include = "quick_spirit_downloader" },
5
- ]
2
+ packages = [{ include = "quickspirit" }]
6
3
  package-mode = true
7
4
  classifiers = [
8
5
  "Intended Audience :: Developers",
@@ -14,7 +11,7 @@ classifiers = [
14
11
  [project]
15
12
  name = "quickspirit"
16
13
  description = "Fast, Async Network & File Downloader Client In Python"
17
- version = "1.0.5"
14
+ version = "2.0.1"
18
15
  dynamic = [ "classifiers" ]
19
16
  license = { text = "GPL-3.0-or-later" }
20
17
  readme = "README.md"
@@ -30,9 +27,6 @@ dependencies = [
30
27
  repository = "https://github.com/DroidZed/QuickSpirit-Async"
31
28
  homepage = "https://github.com/DroidZed/QuickSpirit-Async"
32
29
 
33
- [project.optional-dependencies]
34
- downloader = ["aiofiles"]
35
-
36
30
  [tool.poetry.group.dev.dependencies]
37
31
  pre-commit = "^3.8.0"
38
32
  ruff = "^0.5.5"
@@ -1,8 +1,10 @@
1
+ from .http_async_downloader import HttpAsyncDownloader
1
2
  from .http_errors import RequestError
2
3
  from .http_async_client import HttpAsyncClient
3
4
  from .models import Result
4
5
 
5
6
  __all__ = [
7
+ "HttpAsyncDownloader",
6
8
  "RequestError",
7
9
  "HttpAsyncClient",
8
10
  "Result",
@@ -1,48 +0,0 @@
1
- # Quick Spirit
2
-
3
- An easy to use HTTP client with a fast downloader.
4
-
5
- This library was made with the famous [HTTPX](https://www.python-httpx.org/) library!
6
-
7
- I originally intended to make a small module to refactor my networking layer in my apps using httpx, and ended up creating a library !
8
-
9
- ----
10
-
11
- ## Install
12
-
13
- ```sh
14
- # PIP:
15
-
16
- pip install quickspirit
17
-
18
- # Poetry:
19
-
20
- poetry add quickspirit
21
-
22
- # UV:
23
-
24
- uv add quickspirit
25
- ```
26
-
27
- ## Testing:
28
-
29
- Clone with git:
30
-
31
- ```bash
32
- git clone https://github.com/DroidZed/QuickSpirit-Async && cd QuickSpirit-Async
33
- ```
34
-
35
- Create a virtual env:
36
-
37
- ```sh
38
- python3 -m venv .venv && .venv/Scripts/activate
39
- ```
40
-
41
- Run the tests with pytest (install it first using your package manager of choice):
42
-
43
- ```sh
44
- # Here I'm using uv to run the tests, but the command should be the same for other package manager:
45
-
46
- pytest -vs .
47
- ```
48
-
File without changes
@@ -1,5 +0,0 @@
1
- from .http_async_downloader import HttpAsyncDownloader
2
-
3
- __all__ = [
4
- "HttpAsyncDownloader",
5
- ]
@@ -1,16 +0,0 @@
1
- import pytest
2
-
3
- from ..downloader import HttpAsyncDownloader
4
-
5
-
6
- class TestHttpDownloader:
7
- @pytest.mark.asyncio
8
- async def test_should_download_file(self):
9
- client = HttpAsyncDownloader()
10
- await client.get_file_from_url(
11
- "https://api.coinpaprika.com/v1/coins",
12
- "./db.json",
13
- )
14
-
15
- with open("./db.json", "r") as f:
16
- assert f is not None
File without changes
File without changes
@@ -1,65 +0,0 @@
1
- import pytest
2
- from typing import Any
3
- from dataclasses import dataclass
4
- from json import loads
5
-
6
- from ..http import HttpAsyncClient
7
-
8
-
9
- @dataclass
10
- class CharacterData:
11
- id: int
12
- name: str
13
-
14
- def __init__(self, json: dict[str, Any]):
15
- self.id = json["id"]
16
- self.name = json["name"]
17
-
18
-
19
- @dataclass
20
- class AnimeData:
21
- id: int
22
- name: str
23
- altName: str
24
-
25
- def __init__(self, json: dict[str, Any]):
26
- self.id = json["id"]
27
- self.name = json["name"]
28
- self.altName = json["altName"]
29
-
30
-
31
- @dataclass
32
- class QuoteData:
33
- content: str
34
- anime: AnimeData
35
- character: CharacterData
36
-
37
- def __init__(self, json: dict[str, Any]):
38
- self.content = json["content"]
39
- self.anime = AnimeData(json["anime"])
40
- self.character = CharacterData(json["character"])
41
-
42
-
43
- @dataclass
44
- class Quote:
45
- status: str
46
- data: QuoteData
47
-
48
- def __init__(self, json: dict[str, Any]):
49
- self.status = json["status"]
50
- self.data = QuoteData(json["data"])
51
-
52
-
53
- class TestNetworkClient:
54
- @pytest.mark.asyncio
55
- async def test_should_get_a_random_anime_quote(self):
56
- client = HttpAsyncClient()
57
- data = await client.get("https://animechan.io/api/v1/quotes/random")
58
-
59
- assert data.Error is None
60
-
61
- content: Quote = Quote(loads(data.Data))
62
-
63
- assert content.status == "success"
64
-
65
- print(content)
File without changes