snap-python 0.0.2__tar.gz → 0.0.3__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.
- {snap_python-0.0.2 → snap_python-0.0.3}/PKG-INFO +1 -1
- {snap_python-0.0.2 → snap_python-0.0.3}/pyproject.toml +3 -1
- snap_python-0.0.3/src/snap_python/__init__.py +7 -0
- {snap_python-0.0.2 → snap_python-0.0.3}/src/snap_python/client.py +26 -0
- snap_python-0.0.2/src/snap_python/__init__.py +0 -18
- {snap_python-0.0.2 → snap_python-0.0.3}/LICENSE +0 -0
- {snap_python-0.0.2 → snap_python-0.0.3}/README.md +0 -0
- {snap_python-0.0.2 → snap_python-0.0.3}/src/snap_python/components/__init__.py +0 -0
- {snap_python-0.0.2 → snap_python-0.0.3}/src/snap_python/components/config.py +0 -0
- {snap_python-0.0.2 → snap_python-0.0.3}/src/snap_python/components/snaps.py +0 -0
- {snap_python-0.0.2 → snap_python-0.0.3}/src/snap_python/components/store.py +0 -0
- {snap_python-0.0.2 → snap_python-0.0.3}/src/snap_python/schemas/changes.py +0 -0
- {snap_python-0.0.2 → snap_python-0.0.3}/src/snap_python/schemas/common.py +0 -0
- {snap_python-0.0.2 → snap_python-0.0.3}/src/snap_python/schemas/config.py +0 -0
- {snap_python-0.0.2 → snap_python-0.0.3}/src/snap_python/schemas/snaps.py +0 -0
- {snap_python-0.0.2 → snap_python-0.0.3}/src/snap_python/schemas/store/__init__.py +0 -0
- {snap_python-0.0.2 → snap_python-0.0.3}/src/snap_python/schemas/store/categories.py +0 -0
- {snap_python-0.0.2 → snap_python-0.0.3}/src/snap_python/schemas/store/info.py +0 -0
- {snap_python-0.0.2 → snap_python-0.0.3}/src/snap_python/schemas/store/json/category_by_name_schema.json +0 -0
- {snap_python-0.0.2 → snap_python-0.0.3}/src/snap_python/schemas/store/json/category_schema.json +0 -0
- {snap_python-0.0.2 → snap_python-0.0.3}/src/snap_python/schemas/store/json/snaps_find_schema.json +0 -0
- {snap_python-0.0.2 → snap_python-0.0.3}/src/snap_python/schemas/store/json/snaps_info_schema.json +0 -0
- {snap_python-0.0.2 → snap_python-0.0.3}/src/snap_python/schemas/store/search.py +0 -0
- {snap_python-0.0.2 → snap_python-0.0.3}/src/snap_python/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "snap-python"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.3"
|
|
4
4
|
description = "An api to interact with snapd and snap stores"
|
|
5
5
|
authors = ["Alexander Lukens <alexdlukens@gmail.com>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -21,6 +21,8 @@ ruff = "^0.7.4"
|
|
|
21
21
|
pre-commit = "^4.0.1"
|
|
22
22
|
ipykernel = "^6.29.5"
|
|
23
23
|
pytest-cov = "^6.0.0"
|
|
24
|
+
sphinx = "^8.1.3"
|
|
25
|
+
sphinx-rtd-theme = "^3.0.2"
|
|
24
26
|
|
|
25
27
|
[build-system]
|
|
26
28
|
requires = ["poetry-core"]
|
|
@@ -18,6 +18,8 @@ logger.setLevel(logging.DEBUG)
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class SnapClient(AbstractSnapsClient):
|
|
21
|
+
"""Core class for interacting with the Snap Store and Snapd."""
|
|
22
|
+
|
|
21
23
|
def __init__(
|
|
22
24
|
self,
|
|
23
25
|
version: str = "v2",
|
|
@@ -56,6 +58,18 @@ class SnapClient(AbstractSnapsClient):
|
|
|
56
58
|
|
|
57
59
|
@retry(httpx.HTTPError, tries=3, delay=1, backoff=1)
|
|
58
60
|
async def request(self, method: str, endpoint: str, **kwargs) -> httpx.Response:
|
|
61
|
+
"""
|
|
62
|
+
Sends an HTTP request to the specified endpoint using the given method and parameters.
|
|
63
|
+
Args:
|
|
64
|
+
method (str): The HTTP method to use for the request (e.g., 'GET', 'POST').
|
|
65
|
+
endpoint (str): The API endpoint to send the request to.
|
|
66
|
+
**kwargs: Additional keyword arguments to pass to the request.
|
|
67
|
+
Returns:
|
|
68
|
+
httpx.Response: The response object from the HTTP request.
|
|
69
|
+
Raises:
|
|
70
|
+
httpx.HTTPStatusError: If the response contains an HTTP status code indicating an error.
|
|
71
|
+
"""
|
|
72
|
+
|
|
59
73
|
response = await self.snapd_client.request(
|
|
60
74
|
method, f"{self._base_url}/{self.version}/{endpoint}", **kwargs
|
|
61
75
|
)
|
|
@@ -64,6 +78,18 @@ class SnapClient(AbstractSnapsClient):
|
|
|
64
78
|
|
|
65
79
|
@retry(httpx.HTTPError, tries=3, delay=1, backoff=1)
|
|
66
80
|
async def request_raw(self, method: str, endpoint: str, **kwargs) -> httpx.Response:
|
|
81
|
+
"""
|
|
82
|
+
Sends an HTTP request using the specified method and endpoint.
|
|
83
|
+
Args:
|
|
84
|
+
method (str): The HTTP method to use for the request (e.g., 'GET', 'POST').
|
|
85
|
+
endpoint (str): The endpoint URL to send the request to.
|
|
86
|
+
**kwargs: Additional keyword arguments to pass to the request.
|
|
87
|
+
Returns:
|
|
88
|
+
httpx.Response: The response object resulting from the HTTP request.
|
|
89
|
+
Raises:
|
|
90
|
+
httpx.HTTPStatusError: If the response contains an HTTP status code indicating an error.
|
|
91
|
+
"""
|
|
92
|
+
|
|
67
93
|
response = await self.snapd_client.request(method, endpoint, **kwargs)
|
|
68
94
|
|
|
69
95
|
response.raise_for_status()
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
import os
|
|
3
|
-
|
|
4
|
-
log_level = os.getenv("SNAP_PYTHON_LOG_LEVEL", "DEBUG").upper()
|
|
5
|
-
numeric_level = getattr(logging, log_level, logging.DEBUG)
|
|
6
|
-
logger = logging.getLogger("snap_python")
|
|
7
|
-
logger.setLevel(numeric_level)
|
|
8
|
-
|
|
9
|
-
ch = logging.StreamHandler()
|
|
10
|
-
ch.setLevel(numeric_level)
|
|
11
|
-
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
|
12
|
-
ch.setFormatter(formatter)
|
|
13
|
-
logger.addHandler(ch)
|
|
14
|
-
|
|
15
|
-
fh = logging.FileHandler("snap_python.log")
|
|
16
|
-
fh.setLevel(numeric_level)
|
|
17
|
-
fh.setFormatter(formatter)
|
|
18
|
-
logger.addHandler(fh)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{snap_python-0.0.2 → snap_python-0.0.3}/src/snap_python/schemas/store/json/category_schema.json
RENAMED
|
File without changes
|
{snap_python-0.0.2 → snap_python-0.0.3}/src/snap_python/schemas/store/json/snaps_find_schema.json
RENAMED
|
File without changes
|
{snap_python-0.0.2 → snap_python-0.0.3}/src/snap_python/schemas/store/json/snaps_info_schema.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|