ddapi 0.13.0__tar.gz → 0.13.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.
- {ddapi-0.13.0 → ddapi-0.13.1}/PKG-INFO +1 -1
- {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/__init__.py +1 -1
- {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/_api.py +7 -10
- {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/cache/memory.py +3 -4
- {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/scheme/ddnet.py +3 -3
- {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi.egg-info/PKG-INFO +1 -1
- {ddapi-0.13.0 → ddapi-0.13.1}/setup.cfg +1 -1
- {ddapi-0.13.0 → ddapi-0.13.1}/setup.py +1 -1
- {ddapi-0.13.0 → ddapi-0.13.1}/LICENSE +0 -0
- {ddapi-0.13.0 → ddapi-0.13.1}/README.md +0 -0
- {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/api/__init__.py +0 -0
- {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/api/ddnet.py +0 -0
- {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/api/ddstats.py +0 -0
- {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/api/status.py +0 -0
- {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/cache/__init__.py +0 -0
- {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/cache/base.py +0 -0
- {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/cache/empty.py +0 -0
- {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/enum.py +0 -0
- {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/scheme/__init__.py +0 -0
- {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/scheme/ddstats_tw.py +0 -0
- {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/scheme/status_tw.py +0 -0
- {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/types.py +0 -0
- {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi.egg-info/SOURCES.txt +0 -0
- {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi.egg-info/dependency_links.txt +0 -0
- {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi.egg-info/top_level.txt +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
+
import atexit
|
|
2
3
|
import logging
|
|
3
4
|
from abc import ABC
|
|
4
5
|
from typing import Optional, Type, Any
|
|
@@ -18,6 +19,7 @@ except ImportError:
|
|
|
18
19
|
|
|
19
20
|
logger = logging.getLogger(__name__)
|
|
20
21
|
|
|
22
|
+
|
|
21
23
|
class API(ABC):
|
|
22
24
|
def __init__(
|
|
23
25
|
self,
|
|
@@ -36,6 +38,8 @@ class API(ABC):
|
|
|
36
38
|
self.__session = aiohttp.ClientSession()
|
|
37
39
|
logger.debug("Created a new aiohttp ClientSession.")
|
|
38
40
|
|
|
41
|
+
atexit.register(self.close_api)
|
|
42
|
+
|
|
39
43
|
async def __aenter__(self):
|
|
40
44
|
if self.__session is None:
|
|
41
45
|
self.__session = aiohttp.ClientSession()
|
|
@@ -47,16 +51,6 @@ class API(ABC):
|
|
|
47
51
|
logger.debug("Closing aiohttp ClientSession on exit.")
|
|
48
52
|
await self.close()
|
|
49
53
|
|
|
50
|
-
def __del__(self):
|
|
51
|
-
if self.__session is not None and not self.__session.closed:
|
|
52
|
-
loop = asyncio.get_event_loop()
|
|
53
|
-
if loop.is_running():
|
|
54
|
-
logger.warning("Closing aiohttp ClientSession in the background.")
|
|
55
|
-
loop.create_task(self.close())
|
|
56
|
-
else:
|
|
57
|
-
logger.warning("Closing aiohttp ClientSession synchronously.")
|
|
58
|
-
loop.run_until_complete(self.close())
|
|
59
|
-
|
|
60
54
|
async def _get(self, url: str) -> Optional[dict]:
|
|
61
55
|
"""Send a GET request to the given URL and return the response as JSON."""
|
|
62
56
|
logger.debug(f"Sending GET request to {url}.")
|
|
@@ -116,3 +110,6 @@ class API(ABC):
|
|
|
116
110
|
@staticmethod
|
|
117
111
|
def powered() -> None:
|
|
118
112
|
return None
|
|
113
|
+
|
|
114
|
+
def close_api(self):
|
|
115
|
+
asyncio.run(self.close())
|
|
@@ -11,10 +11,9 @@ class MemoryCache(CacheABC):
|
|
|
11
11
|
|
|
12
12
|
async def set(self, key: str, value: Any, timeout_seconds: int = None) -> bool:
|
|
13
13
|
async with self._lock:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
asyncio.create_task(self._remove_after_timeout(key, timeout_seconds))
|
|
14
|
+
self._cache[key] = value
|
|
15
|
+
if timeout_seconds is not None:
|
|
16
|
+
asyncio.create_task(self._remove_after_timeout(key, timeout_seconds))
|
|
18
17
|
return True
|
|
19
18
|
|
|
20
19
|
async def delete(self, key: str) -> bool:
|
|
@@ -265,9 +265,9 @@ class ReleasesMapsData(BaseModel):
|
|
|
265
265
|
difficulty: int
|
|
266
266
|
mapper: str
|
|
267
267
|
release: datetime | str
|
|
268
|
-
width: int
|
|
269
|
-
height: int
|
|
270
|
-
tiles: list[str]
|
|
268
|
+
width: int = None
|
|
269
|
+
height: int = None
|
|
270
|
+
tiles: list[str] = None
|
|
271
271
|
|
|
272
272
|
|
|
273
273
|
class ReleasesMaps(BaseModel):
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|