ddapi 0.4.8__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.
- {ddapi-0.4.8 → ddapi-0.5.0}/PKG-INFO +1 -1
- {ddapi-0.4.8 → ddapi-0.5.0}/ddapi/ddapi/dataclass.py +24 -16
- {ddapi-0.4.8 → ddapi-0.5.0}/ddapi/ddapi.egg-info/PKG-INFO +1 -1
- {ddapi-0.4.8 → ddapi-0.5.0}/pyproject.toml +1 -1
- {ddapi-0.4.8 → ddapi-0.5.0}/setup.cfg +1 -1
- {ddapi-0.4.8 → ddapi-0.5.0}/setup.py +1 -1
- {ddapi-0.4.8 → ddapi-0.5.0}/LICENSE +0 -0
- {ddapi-0.4.8 → ddapi-0.5.0}/README.md +0 -0
- {ddapi-0.4.8 → ddapi-0.5.0}/ddapi/ddapi/__init__.py +0 -0
- {ddapi-0.4.8 → ddapi-0.5.0}/ddapi/ddapi/deflt.py +0 -0
- {ddapi-0.4.8 → ddapi-0.5.0}/ddapi/ddapi/main.py +0 -0
- {ddapi-0.4.8 → ddapi-0.5.0}/ddapi/ddapi.egg-info/SOURCES.txt +0 -0
- {ddapi-0.4.8 → ddapi-0.5.0}/ddapi/ddapi.egg-info/dependency_links.txt +0 -0
- {ddapi-0.4.8 → ddapi-0.5.0}/ddapi/ddapi.egg-info/requires.txt +0 -0
- {ddapi-0.4.8 → ddapi-0.5.0}/ddapi/ddapi.egg-info/top_level.txt +0 -0
|
@@ -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
|
|
|
@@ -360,14 +361,14 @@ class Client(BaseModel):
|
|
|
360
361
|
|
|
361
362
|
|
|
362
363
|
class Info(BaseModel):
|
|
363
|
-
max_clients: int = Field(default=0)
|
|
364
|
-
max_players: int = Field(default=0)
|
|
365
|
-
passworded: bool = Field(default=None)
|
|
366
|
-
game_type: str = Field(default=None)
|
|
367
|
-
name: str = Field(default=None)
|
|
368
|
-
map: dict = Field(default=None)
|
|
369
|
-
version: str = Field(default=None)
|
|
370
|
-
clients: list[Client] = Field(default=None)
|
|
364
|
+
max_clients: int | None = Field(default=0)
|
|
365
|
+
max_players: int | None = Field(default=0)
|
|
366
|
+
passworded: bool | None = Field(default=None)
|
|
367
|
+
game_type: str | None = Field(default=None)
|
|
368
|
+
name: str | None = Field(default=None)
|
|
369
|
+
map: dict | None = Field(default=None)
|
|
370
|
+
version: str | None = Field(default=None)
|
|
371
|
+
clients: list[Client] | None = Field(default=None)
|
|
371
372
|
|
|
372
373
|
|
|
373
374
|
class Server(BaseModel):
|
|
@@ -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
|
-
|
|
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 = [
|
|
399
|
-
|
|
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
|
|
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
|