wardy-utils 0.1.0__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.
- wardy_utils-0.1.0/.gitignore +6 -0
- wardy_utils-0.1.0/.python-version +1 -0
- wardy_utils-0.1.0/PKG-INFO +63 -0
- wardy_utils-0.1.0/README.md +46 -0
- wardy_utils-0.1.0/pyproject.toml +30 -0
- wardy_utils-0.1.0/src/wardy_utils/__init__.py +2 -0
- wardy_utils-0.1.0/src/wardy_utils/py.typed +0 -0
- wardy_utils-0.1.0/src/wardy_utils/web.py +38 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.13.3
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: wardy-utils
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: General Utilities
|
|
5
|
+
Author-email: Wardy <wardy3+gitlab@gmail.com>
|
|
6
|
+
Classifier: Development Status :: 4 - Beta
|
|
7
|
+
Classifier: Intended Audience :: Developers
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
13
|
+
Requires-Python: >=3.13.3
|
|
14
|
+
Requires-Dist: hishel>=0.1.2
|
|
15
|
+
Requires-Dist: httpx>=0.28.1
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# Wardy Utils
|
|
19
|
+
|
|
20
|
+
**Wardy Utils** is a collection of general-purpose utilities designed to simplify and enhance your Python scripting experience. This library provides reusable components that can be integrated into your projects to save time and effort.
|
|
21
|
+
|
|
22
|
+
## Features
|
|
23
|
+
|
|
24
|
+
### HTTP Utilities
|
|
25
|
+
|
|
26
|
+
- **`http`**: A high-level HTTP client built on top of `httpx` and `hishel`, setting some caching and timeout comment settings.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
To install Wardy Utils, use pip:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install wardy-utils
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
### HTTP Client Example
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from wardy_utils.web import CachedClient
|
|
42
|
+
|
|
43
|
+
client = CachedClient()
|
|
44
|
+
response = client.get("https://example.com")
|
|
45
|
+
print(response.text)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Requirements
|
|
49
|
+
|
|
50
|
+
- Python 3.13.3 or higher
|
|
51
|
+
|
|
52
|
+
## Contributing
|
|
53
|
+
|
|
54
|
+
Contributions are welcome! Feel free to open issues or submit pull requests to improve the library.
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
|
|
58
|
+
This project is licensed under the MIT License.
|
|
59
|
+
|
|
60
|
+
## Author
|
|
61
|
+
|
|
62
|
+
Created by **Wardy**
|
|
63
|
+
Email: [wardy3+gitlab@gmail.com](mailto:wardy3+gitlab@gmail.com)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Wardy Utils
|
|
2
|
+
|
|
3
|
+
**Wardy Utils** is a collection of general-purpose utilities designed to simplify and enhance your Python scripting experience. This library provides reusable components that can be integrated into your projects to save time and effort.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
### HTTP Utilities
|
|
8
|
+
|
|
9
|
+
- **`http`**: A high-level HTTP client built on top of `httpx` and `hishel`, setting some caching and timeout comment settings.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
To install Wardy Utils, use pip:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install wardy-utils
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### HTTP Client Example
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from wardy_utils.web import CachedClient
|
|
25
|
+
|
|
26
|
+
client = CachedClient()
|
|
27
|
+
response = client.get("https://example.com")
|
|
28
|
+
print(response.text)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Requirements
|
|
32
|
+
|
|
33
|
+
- Python 3.13.3 or higher
|
|
34
|
+
|
|
35
|
+
## Contributing
|
|
36
|
+
|
|
37
|
+
Contributions are welcome! Feel free to open issues or submit pull requests to improve the library.
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
This project is licensed under the MIT License.
|
|
42
|
+
|
|
43
|
+
## Author
|
|
44
|
+
|
|
45
|
+
Created by **Wardy**
|
|
46
|
+
Email: [wardy3+gitlab@gmail.com](mailto:wardy3+gitlab@gmail.com)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
authors = [{ name = "Wardy", email = "wardy3+gitlab@gmail.com" }]
|
|
3
|
+
description = "General Utilities"
|
|
4
|
+
name = "wardy-utils"
|
|
5
|
+
readme = { file = "README.md", content-type = "text/markdown" }
|
|
6
|
+
requires-python = ">=3.13.3"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Development Status :: 4 - Beta",
|
|
11
|
+
"Intended Audience :: Developers",
|
|
12
|
+
"License :: OSI Approved :: MIT License",
|
|
13
|
+
"Operating System :: OS Independent",
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"Programming Language :: Python :: 3.13",
|
|
16
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
dependencies = ["hishel>=0.1.2", "httpx>=0.28.1"]
|
|
20
|
+
|
|
21
|
+
[build-system]
|
|
22
|
+
build-backend = "hatchling.build"
|
|
23
|
+
requires = ["hatchling"]
|
|
24
|
+
|
|
25
|
+
[[tool.uv.index]]
|
|
26
|
+
explicit = true
|
|
27
|
+
name = "private-idaho"
|
|
28
|
+
|
|
29
|
+
publish-url = "https://gitlab.com/api/v4/projects/68880898/packages/pypi"
|
|
30
|
+
url = "https://gitlab.com/api/v4/projects/68880898/packages/pypi/simple"
|
|
File without changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""General internet helpers."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
from datetime import timedelta
|
|
7
|
+
from typing import Final
|
|
8
|
+
|
|
9
|
+
import hishel
|
|
10
|
+
|
|
11
|
+
logging.getLogger("hishel.controller").setLevel(logging.DEBUG)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class CachedClient(hishel.CacheClient):
|
|
15
|
+
"""Handle httpx client and hishel caching."""
|
|
16
|
+
|
|
17
|
+
def __init__(
|
|
18
|
+
self, *, force_cache: bool = False, cache_minutes: int = 30, timeout_seconds: int = 20
|
|
19
|
+
) -> None:
|
|
20
|
+
"""Initialize the client.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
force_cache (bool): Force cache to be used on all pages.
|
|
24
|
+
cache_minutes (int): Number of minutes to cache.
|
|
25
|
+
timeout_seconds (int): Number of seconds to timeout.
|
|
26
|
+
"""
|
|
27
|
+
cache: Final = timedelta(minutes=cache_minutes).total_seconds()
|
|
28
|
+
timeout: Final = timedelta(seconds=timeout_seconds).total_seconds()
|
|
29
|
+
|
|
30
|
+
self.storage = hishel.FileStorage(ttl=cache)
|
|
31
|
+
self.controller = hishel.Controller(force_cache=force_cache)
|
|
32
|
+
|
|
33
|
+
super().__init__(
|
|
34
|
+
follow_redirects=True,
|
|
35
|
+
storage=self.storage,
|
|
36
|
+
controller=self.controller,
|
|
37
|
+
timeout=timeout,
|
|
38
|
+
)
|