ddapi 0.4.9__tar.gz → 0.5.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ddapi
3
- Version: 0.4.9
3
+ Version: 0.5.0
4
4
  Summary: ddapi
5
5
  Home-page: https://github.com/ByFox213/ddapi
6
6
  Author: ByFox
@@ -1,9 +1,10 @@
1
1
  # pylint: disable-all
2
2
  from collections import Counter
3
3
  from datetime import datetime
4
- from typing import Optional, Union, Any
4
+ from typing import Optional, Union, Any, AsyncGenerator
5
5
  from pydantic import BaseModel, Field
6
6
 
7
+ rm_list = ["DD-Persian", "/vDQMHSss8W"]
7
8
 
8
9
  # DDStats
9
10
 
@@ -376,33 +377,40 @@ class Server(BaseModel):
376
377
  info: Info = Field(default=None)
377
378
 
378
379
  def get_count_client(self) -> int:
379
- return len(self.info.clients)
380
+ if self.info is not None and self.info.clients is not None:
381
+ return len(self.info.clients)
382
+ return 0
380
383
 
381
384
 
382
385
  class Master(BaseModel):
383
386
  servers: list[Server]
384
387
 
385
- async def get_info(self):
388
+ async def get_info(self) -> AsyncGenerator[Info, None]:
386
389
  for i in self.servers:
390
+ if i.info is None:
391
+ continue
387
392
  yield i.info
388
393
 
389
- async def get_clients(self):
394
+ async def get_clients(self) -> AsyncGenerator[Client, None]:
390
395
  for i in self.servers:
396
+ if i.info is None or i.info.clients is None:
397
+ continue
391
398
  yield i.info.clients
392
399
 
393
400
  def get_count(self) -> int:
394
401
  return len(self.servers)
395
402
 
396
- def get_clans(self, limit: int = 50, rm=None):
403
+ def get_clans(self, limit: int = 50, rm: list[str] = None) -> list[tuple[Any, int]]:
397
404
  if rm is None:
398
- rm = ["DD-Persian"]
399
- dat = Counter(client.clan for server in self.servers for client in server.info.clients)
405
+ rm = []
406
+ rm.extend(rm_list)
407
+ dat = Counter(client.clan for server in self.servers for client in server.info.clients if server.info is not None and server.info.clients is not None)
400
408
  del dat['']
401
409
  for i in rm:
402
410
  del dat[i]
403
411
  return sorted(dat.items(), key=lambda x: x[1], reverse=True)[:limit]
404
412
 
405
- def get_count_servers(self, limit: int = 10):
413
+ def get_count_servers(self, limit: int = 10) -> list[tuple[int, list | Any, str | None, str | None]]:
406
414
  dat = []
407
415
  for i in self.servers:
408
416
  add = i.addresses
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ddapi
3
- Version: 0.4.9
3
+ Version: 0.5.0
4
4
  Summary: ddapi
5
5
  Home-page: https://github.com/ByFox213/ddapi
6
6
  Author: ByFox
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ddapi"
7
- version = "0.4.9"
7
+ version = "0.5.0"
8
8
  description = "ddapi"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "ByFox" }]
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = ddapi
3
- version = 0.4.9
3
+ version = 0.5.0
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-py",
8
- version="0.4.9",
8
+ version="0.5.0",
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