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.
Files changed (25) hide show
  1. {ddapi-0.13.0 → ddapi-0.13.1}/PKG-INFO +1 -1
  2. {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/__init__.py +1 -1
  3. {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/_api.py +7 -10
  4. {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/cache/memory.py +3 -4
  5. {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/scheme/ddnet.py +3 -3
  6. {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi.egg-info/PKG-INFO +1 -1
  7. {ddapi-0.13.0 → ddapi-0.13.1}/setup.cfg +1 -1
  8. {ddapi-0.13.0 → ddapi-0.13.1}/setup.py +1 -1
  9. {ddapi-0.13.0 → ddapi-0.13.1}/LICENSE +0 -0
  10. {ddapi-0.13.0 → ddapi-0.13.1}/README.md +0 -0
  11. {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/api/__init__.py +0 -0
  12. {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/api/ddnet.py +0 -0
  13. {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/api/ddstats.py +0 -0
  14. {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/api/status.py +0 -0
  15. {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/cache/__init__.py +0 -0
  16. {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/cache/base.py +0 -0
  17. {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/cache/empty.py +0 -0
  18. {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/enum.py +0 -0
  19. {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/scheme/__init__.py +0 -0
  20. {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/scheme/ddstats_tw.py +0 -0
  21. {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/scheme/status_tw.py +0 -0
  22. {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi/types.py +0 -0
  23. {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi.egg-info/SOURCES.txt +0 -0
  24. {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi.egg-info/dependency_links.txt +0 -0
  25. {ddapi-0.13.0 → ddapi-0.13.1}/ddapi/ddapi.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ddapi
3
- Version: 0.13.0
3
+ Version: 0.13.1
4
4
  Summary: DDnet api
5
5
  Home-page: https://github.com/ByFox213/ddapi
6
6
  Author: ByFox
@@ -5,6 +5,6 @@ from .enum import MasterEnum
5
5
  from .cache import CacheABC, EmptyCache, MemoryCache
6
6
  from .scheme import * # noqa: F403
7
7
 
8
- __version__ = "0.13.0"
8
+ __version__ = "0.13.1"
9
9
  __author__ = "ByFox"
10
10
  __LICENSE__ = "MIT"
@@ -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
- if timeout_seconds is None:
15
- self._cache[key] = value
16
- return True
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):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ddapi
3
- Version: 0.13.0
3
+ Version: 0.13.1
4
4
  Summary: DDnet api
5
5
  Home-page: https://github.com/ByFox213/ddapi
6
6
  Author: ByFox
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = ddapi
3
- version = 0.12.2
3
+ version = 0.13.1
4
4
  author = ByFox
5
5
  description = DDnet api
6
6
  long_description = file: README.md
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="ddapi",
8
- version="0.13.0",
8
+ version="0.13.1",
9
9
  author="ByFox",
10
10
  description="DDnet api",
11
11
  long_description=long_description,
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes