diff options
| -rw-r--r-- | src/lib/szurubooru.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/lib/szurubooru.py b/src/lib/szurubooru.py index 8649368..7438f76 100644 --- a/src/lib/szurubooru.py +++ b/src/lib/szurubooru.py @@ -369,6 +369,7 @@ class Szurubooru: requests_get: int = 0 requests_post: int = 0 requests_put: int = 0 + requests_delete: int = 0 def __init__(self, url: str, token: str, verify: bool = True): self.url = url @@ -391,13 +392,14 @@ class Szurubooru: return wrapper @staticmethod - def __count_stats(get: int = 0, post: int = 0, put: int = 0): + def __count_stats(get: int = 0, post: int = 0, put: int = 0, delete: int = 0): def function_wrapper(func): @functools.wraps(func) def wrapper(self, **kwargs): self.requests_get += get self.requests_post += post self.requests_put += put + self.requests_delete += delete return func(self, **kwargs) return wrapper @@ -433,6 +435,17 @@ class Szurubooru: data=json.dumps(params), ) + @__count_stats(delete=1) + @__raise_szurubooru_exception + def __delete(self, path: str, params: dict) -> r.Response: + return r.delete( + f"{self.url}{path}", + timeout=15, + verify=self.verify, + headers=self.header, + data=json.dumps(params), + ) + def __map_tag_resource_response(self, res: r.Response, name: str = "") -> Tag: """Maps the requests response from the Szurubooru REST API to the Tag dataclass. |