lpdb_python 0.1.2__tar.gz → 0.2.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.
- {lpdb_python-0.1.2 → lpdb_python-0.2.0}/.github/workflows/ci.yml +3 -5
- lpdb_python-0.2.0/.github/workflows/publish.yml +74 -0
- {lpdb_python-0.1.2 → lpdb_python-0.2.0}/PKG-INFO +27 -4
- {lpdb_python-0.1.2 → lpdb_python-0.2.0}/README.md +26 -3
- lpdb_python-0.2.0/docs/module.html.jinja2 +9 -0
- {lpdb_python-0.1.2 → lpdb_python-0.2.0}/pyproject.toml +8 -1
- {lpdb_python-0.1.2 → lpdb_python-0.2.0}/src/lpdb_python/__init__.py +21 -2
- {lpdb_python-0.1.2 → lpdb_python-0.2.0}/src/lpdb_python/async_session/async_session.py +3 -3
- {lpdb_python-0.1.2 → lpdb_python-0.2.0}/src/lpdb_python/defs.py +5 -29
- {lpdb_python-0.1.2 → lpdb_python-0.2.0}/src/lpdb_python/session.py +22 -9
- {lpdb_python-0.1.2 → lpdb_python-0.2.0}/src/lpdb_python.egg-info/PKG-INFO +27 -4
- {lpdb_python-0.1.2 → lpdb_python-0.2.0}/src/lpdb_python.egg-info/SOURCES.txt +1 -0
- {lpdb_python-0.1.2 → lpdb_python-0.2.0}/tests/test_data_wrapper.py +1 -1
- lpdb_python-0.1.2/.github/workflows/publish.yml +0 -33
- {lpdb_python-0.1.2 → lpdb_python-0.2.0}/.gitignore +0 -0
- {lpdb_python-0.1.2 → lpdb_python-0.2.0}/LICENSE +0 -0
- {lpdb_python-0.1.2 → lpdb_python-0.2.0}/setup.cfg +0 -0
- {lpdb_python-0.1.2 → lpdb_python-0.2.0}/src/lpdb_python/async_session/__init__.py +0 -0
- {lpdb_python-0.1.2 → lpdb_python-0.2.0}/src/lpdb_python.egg-info/dependency_links.txt +0 -0
- {lpdb_python-0.1.2 → lpdb_python-0.2.0}/src/lpdb_python.egg-info/requires.txt +0 -0
- {lpdb_python-0.1.2 → lpdb_python-0.2.0}/src/lpdb_python.egg-info/top_level.txt +0 -0
- {lpdb_python-0.1.2 → lpdb_python-0.2.0}/tests/data/sample_match_data.json +0 -0
- {lpdb_python-0.1.2 → lpdb_python-0.2.0}/tests/test_async_session.py +0 -0
- {lpdb_python-0.1.2 → lpdb_python-0.2.0}/tests/test_session.py +0 -0
|
@@ -51,9 +51,7 @@ jobs:
|
|
|
51
51
|
steps:
|
|
52
52
|
- name: Checkout repository
|
|
53
53
|
uses: actions/checkout@v6
|
|
54
|
-
- name:
|
|
55
|
-
uses:
|
|
56
|
-
with:
|
|
57
|
-
python-version-file: "pyproject.toml"
|
|
54
|
+
- name: Run linter
|
|
55
|
+
uses: astral-sh/ruff-action@v3
|
|
58
56
|
- name: Check styling
|
|
59
|
-
|
|
57
|
+
run: ruff format --check --diff
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
# Publish on any tag starting with a `v`, e.g., v0.1.0
|
|
7
|
+
- v*
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
run:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
environment:
|
|
13
|
+
name: pypi
|
|
14
|
+
permissions:
|
|
15
|
+
id-token: write
|
|
16
|
+
contents: read
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout
|
|
19
|
+
uses: actions/checkout@v6
|
|
20
|
+
|
|
21
|
+
- name: Setup Python
|
|
22
|
+
uses: actions/setup-python@v6
|
|
23
|
+
with:
|
|
24
|
+
python-version-file: "pyproject.toml"
|
|
25
|
+
|
|
26
|
+
- name: Install uv
|
|
27
|
+
uses: astral-sh/setup-uv@v7
|
|
28
|
+
|
|
29
|
+
- name: Build
|
|
30
|
+
run: uv build
|
|
31
|
+
|
|
32
|
+
- name: Publish
|
|
33
|
+
run: uv publish
|
|
34
|
+
|
|
35
|
+
# Build the documentation and upload the static HTML files as an artifact.
|
|
36
|
+
build-docs:
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
steps:
|
|
39
|
+
- name: Checkout
|
|
40
|
+
uses: actions/checkout@v6
|
|
41
|
+
|
|
42
|
+
- name: Setup Python
|
|
43
|
+
uses: actions/setup-python@v6
|
|
44
|
+
with:
|
|
45
|
+
python-version-file: "pyproject.toml"
|
|
46
|
+
|
|
47
|
+
- name: Install uv
|
|
48
|
+
uses: astral-sh/setup-uv@v7
|
|
49
|
+
|
|
50
|
+
- name: Setup project
|
|
51
|
+
run: uv sync --all-extras --dev
|
|
52
|
+
|
|
53
|
+
- name: Build docs
|
|
54
|
+
run: uv run pdoc lpdb_python.defs lpdb_python.session lpdb_python.async_session -t docs/ -o output/docs/
|
|
55
|
+
env:
|
|
56
|
+
VERSION: ${{ github.ref_name }}
|
|
57
|
+
|
|
58
|
+
- uses: actions/upload-pages-artifact@v4
|
|
59
|
+
with:
|
|
60
|
+
path: output/docs/
|
|
61
|
+
|
|
62
|
+
deploy:
|
|
63
|
+
needs: build-docs
|
|
64
|
+
runs-on: ubuntu-latest
|
|
65
|
+
permissions:
|
|
66
|
+
pages: write
|
|
67
|
+
id-token: write
|
|
68
|
+
environment:
|
|
69
|
+
name: github-pages
|
|
70
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
71
|
+
steps:
|
|
72
|
+
- name: Deploy
|
|
73
|
+
id: deployment
|
|
74
|
+
uses: actions/deploy-pages@v4
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lpdb_python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Author-email: ElectricalBoy <electricalboy01@gmail.com>
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Project-URL: Homepage, https://github.com/ElectricalBoy/LPDB_python
|
|
@@ -25,7 +25,21 @@ Dynamic: license-file
|
|
|
25
25
|
|
|
26
26
|
LPDB_python provides Python interfaces for the [Liquipedia Database API](https://liquipedia.net/api) (LPDB API).
|
|
27
27
|
|
|
28
|
-
##
|
|
28
|
+
## What You Need
|
|
29
|
+
|
|
30
|
+
- Python 3.12 or later
|
|
31
|
+
- API key for LPDB
|
|
32
|
+
- (Optional) [aiohttp](https://github.com/aio-libs/aiohttp)
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install lpdb_python
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Basic Uses
|
|
41
|
+
|
|
42
|
+
### LPDB Session
|
|
29
43
|
|
|
30
44
|
Python wrapper for LPDB session is defined in [session.py](src/lpdb_python/session.py). The wrapper provides the following
|
|
31
45
|
differences from making your own requests:
|
|
@@ -45,7 +59,16 @@ differences from making your own requests:
|
|
|
45
59
|
session = lpdb.LpdbSession("Apikey your_lpdb_api_key")
|
|
46
60
|
```
|
|
47
61
|
|
|
48
|
-
|
|
62
|
+
#### Async Session
|
|
63
|
+
|
|
64
|
+
Asynchronous implementation of LPDB session can be found in [async_session/session.py](src/lpdb_python/async_session/async_session.py).
|
|
65
|
+
This implementation depends on [aiohttp](https://github.com/aio-libs/aiohttp), which can be installed with this library with the following command:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install lpdb_python[async]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### LPDB Data Types
|
|
49
72
|
|
|
50
73
|
Data types in LPDB can be found in <https://liquipedia.net/commons/Help:LiquipediaDB>.
|
|
51
74
|
|
|
@@ -57,7 +80,7 @@ A property provided by the wrapper may be `None` if the raw data passed to the c
|
|
|
57
80
|
did not contain the data, or if it contained an empty string. Thus, the user should be checking for `None`
|
|
58
81
|
where appropriate.
|
|
59
82
|
|
|
60
|
-
|
|
83
|
+
#### Example
|
|
61
84
|
|
|
62
85
|
```python
|
|
63
86
|
import lpdb_python as lpdb
|
|
@@ -7,7 +7,21 @@
|
|
|
7
7
|
|
|
8
8
|
LPDB_python provides Python interfaces for the [Liquipedia Database API](https://liquipedia.net/api) (LPDB API).
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## What You Need
|
|
11
|
+
|
|
12
|
+
- Python 3.12 or later
|
|
13
|
+
- API key for LPDB
|
|
14
|
+
- (Optional) [aiohttp](https://github.com/aio-libs/aiohttp)
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install lpdb_python
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Basic Uses
|
|
23
|
+
|
|
24
|
+
### LPDB Session
|
|
11
25
|
|
|
12
26
|
Python wrapper for LPDB session is defined in [session.py](src/lpdb_python/session.py). The wrapper provides the following
|
|
13
27
|
differences from making your own requests:
|
|
@@ -27,7 +41,16 @@ differences from making your own requests:
|
|
|
27
41
|
session = lpdb.LpdbSession("Apikey your_lpdb_api_key")
|
|
28
42
|
```
|
|
29
43
|
|
|
30
|
-
|
|
44
|
+
#### Async Session
|
|
45
|
+
|
|
46
|
+
Asynchronous implementation of LPDB session can be found in [async_session/session.py](src/lpdb_python/async_session/async_session.py).
|
|
47
|
+
This implementation depends on [aiohttp](https://github.com/aio-libs/aiohttp), which can be installed with this library with the following command:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install lpdb_python[async]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### LPDB Data Types
|
|
31
54
|
|
|
32
55
|
Data types in LPDB can be found in <https://liquipedia.net/commons/Help:LiquipediaDB>.
|
|
33
56
|
|
|
@@ -39,7 +62,7 @@ A property provided by the wrapper may be `None` if the raw data passed to the c
|
|
|
39
62
|
did not contain the data, or if it contained an empty string. Thus, the user should be checking for `None`
|
|
40
63
|
where appropriate.
|
|
41
64
|
|
|
42
|
-
|
|
65
|
+
#### Example
|
|
43
66
|
|
|
44
67
|
```python
|
|
45
68
|
import lpdb_python as lpdb
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{% extends "default/module.html.jinja2" %}
|
|
2
|
+
|
|
3
|
+
{% block nav_footer %}
|
|
4
|
+
<footer>
|
|
5
|
+
lpdb_python {{ env["VERSION"] | default("0.0.0") }}
|
|
6
|
+
<br />
|
|
7
|
+
<a href="https://github.com/ElectricalBoy/LPDB_python"><img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/ElectricalBoy/lpdb_python" /></a>
|
|
8
|
+
</footer>
|
|
9
|
+
{% endblock %}
|
|
@@ -32,7 +32,8 @@ async = [
|
|
|
32
32
|
[dependency-groups]
|
|
33
33
|
dev = [
|
|
34
34
|
{include-group = "test"},
|
|
35
|
-
{include-group = "lint"}
|
|
35
|
+
{include-group = "lint"},
|
|
36
|
+
{include-group = "docs"}
|
|
36
37
|
]
|
|
37
38
|
test = [
|
|
38
39
|
"pytest",
|
|
@@ -41,8 +42,14 @@ test = [
|
|
|
41
42
|
lint = [
|
|
42
43
|
"black",
|
|
43
44
|
]
|
|
45
|
+
docs = [
|
|
46
|
+
"pdoc",
|
|
47
|
+
]
|
|
44
48
|
|
|
45
49
|
[tool.pytest.ini_options]
|
|
46
50
|
pythonpath = [
|
|
47
51
|
"src"
|
|
48
52
|
]
|
|
53
|
+
|
|
54
|
+
[tool.ruff]
|
|
55
|
+
target-version = "py312"
|
|
@@ -4,8 +4,27 @@ Python interface for Liquipedia Database (LPDB) API
|
|
|
4
4
|
|
|
5
5
|
import importlib.metadata as _metadata
|
|
6
6
|
|
|
7
|
-
from .defs import
|
|
8
|
-
|
|
7
|
+
from .defs import (
|
|
8
|
+
OpponentType,
|
|
9
|
+
Broadcasters,
|
|
10
|
+
Company,
|
|
11
|
+
Datapoint,
|
|
12
|
+
ExternalMediaLink,
|
|
13
|
+
Match,
|
|
14
|
+
MatchGame,
|
|
15
|
+
MatchOpponent,
|
|
16
|
+
Placement,
|
|
17
|
+
Player,
|
|
18
|
+
Series,
|
|
19
|
+
SquadPlayer,
|
|
20
|
+
StandingsEntry,
|
|
21
|
+
StandingsTable,
|
|
22
|
+
Team,
|
|
23
|
+
Tournament,
|
|
24
|
+
Transfer,
|
|
25
|
+
TeamTemplate,
|
|
26
|
+
)
|
|
27
|
+
from .session import LpdbError, LpdbWarning, LpdbSession
|
|
9
28
|
|
|
10
29
|
__all__ = [
|
|
11
30
|
"OpponentType",
|
|
@@ -4,7 +4,7 @@ from typing import Any, Literal, Optional, override
|
|
|
4
4
|
|
|
5
5
|
import aiohttp
|
|
6
6
|
|
|
7
|
-
from ..session import AbstractLpdbSession, LpdbDataType
|
|
7
|
+
from ..session import AbstractLpdbSession, LpdbDataType
|
|
8
8
|
|
|
9
9
|
__all__ = ["AsyncLpdbSession"]
|
|
10
10
|
|
|
@@ -112,11 +112,11 @@ class AsyncLpdbSession(AbstractLpdbSession):
|
|
|
112
112
|
"wiki": wiki,
|
|
113
113
|
"template": template,
|
|
114
114
|
}
|
|
115
|
-
if date
|
|
115
|
+
if date is not None:
|
|
116
116
|
params["date"] = date.isoformat()
|
|
117
117
|
async with self.__session.get("teamtemplate", params=params) as response:
|
|
118
118
|
parsed_response = await AsyncLpdbSession.__handle_response(response)
|
|
119
|
-
if parsed_response[0]
|
|
119
|
+
if parsed_response[0] is None:
|
|
120
120
|
return None
|
|
121
121
|
return parsed_response[0]
|
|
122
122
|
|
|
@@ -119,7 +119,6 @@ class LpdbBaseResponseData(LpdbBaseData):
|
|
|
119
119
|
|
|
120
120
|
|
|
121
121
|
class Broadcasters(LpdbBaseResponseData):
|
|
122
|
-
|
|
123
122
|
@property
|
|
124
123
|
def id(self) -> str:
|
|
125
124
|
return self._rawGet("id")
|
|
@@ -158,7 +157,6 @@ class Broadcasters(LpdbBaseResponseData):
|
|
|
158
157
|
|
|
159
158
|
|
|
160
159
|
class Company(LpdbBaseResponseData):
|
|
161
|
-
|
|
162
160
|
@property
|
|
163
161
|
def name(self) -> str:
|
|
164
162
|
return self._rawGet("name")
|
|
@@ -213,7 +211,6 @@ class Company(LpdbBaseResponseData):
|
|
|
213
211
|
|
|
214
212
|
|
|
215
213
|
class Datapoint(LpdbBaseResponseData):
|
|
216
|
-
|
|
217
214
|
@property
|
|
218
215
|
def type(self) -> str:
|
|
219
216
|
return self._rawGet("type")
|
|
@@ -244,7 +241,6 @@ class Datapoint(LpdbBaseResponseData):
|
|
|
244
241
|
|
|
245
242
|
|
|
246
243
|
class ExternalMediaLink(LpdbBaseResponseData):
|
|
247
|
-
|
|
248
244
|
@property
|
|
249
245
|
def title(self) -> str:
|
|
250
246
|
return self._rawGet("title")
|
|
@@ -279,7 +275,6 @@ class ExternalMediaLink(LpdbBaseResponseData):
|
|
|
279
275
|
|
|
280
276
|
|
|
281
277
|
class Match(LpdbBaseResponseData):
|
|
282
|
-
|
|
283
278
|
@property
|
|
284
279
|
def match2id(self) -> str:
|
|
285
280
|
return self._rawGet("match2id")
|
|
@@ -341,7 +336,7 @@ class Match(LpdbBaseResponseData):
|
|
|
341
336
|
parsed = _parseIsoDateTime(self._rawGet("date"))
|
|
342
337
|
if not self.dateexact:
|
|
343
338
|
return parsed
|
|
344
|
-
elif self.timezone
|
|
339
|
+
elif self.timezone is not None:
|
|
345
340
|
return parsed.astimezone(tz=self.timezone)
|
|
346
341
|
return parsed
|
|
347
342
|
|
|
@@ -356,10 +351,10 @@ class Match(LpdbBaseResponseData):
|
|
|
356
351
|
"""
|
|
357
352
|
if not self.dateexact:
|
|
358
353
|
return None
|
|
359
|
-
elif self.extradata
|
|
354
|
+
elif self.extradata is None:
|
|
360
355
|
return None
|
|
361
356
|
offset: str = self.extradata.get("timezoneoffset")
|
|
362
|
-
if offset
|
|
357
|
+
if offset is None:
|
|
363
358
|
return None
|
|
364
359
|
sliced_offset = offset.split(":")
|
|
365
360
|
offset_delta = timedelta(
|
|
@@ -427,10 +422,6 @@ class Match(LpdbBaseResponseData):
|
|
|
427
422
|
def match2bracketdata(self) -> dict:
|
|
428
423
|
return self._rawGet("match2bracketdata")
|
|
429
424
|
|
|
430
|
-
@property
|
|
431
|
-
def tickername(self) -> str:
|
|
432
|
-
return self._rawGet("tickername")
|
|
433
|
-
|
|
434
425
|
@property
|
|
435
426
|
def match2games(self) -> list["MatchGame"]:
|
|
436
427
|
return [
|
|
@@ -529,7 +520,6 @@ class MatchGame(LpdbBaseData):
|
|
|
529
520
|
|
|
530
521
|
|
|
531
522
|
class MatchOpponent(LpdbBaseData):
|
|
532
|
-
|
|
533
523
|
@property
|
|
534
524
|
def id(self) -> int:
|
|
535
525
|
return self._rawGet("id")
|
|
@@ -566,13 +556,9 @@ class MatchOpponent(LpdbBaseData):
|
|
|
566
556
|
def match2players(self) -> list[dict]:
|
|
567
557
|
return self._rawGet("match2players")
|
|
568
558
|
|
|
569
|
-
@property
|
|
570
|
-
def extradata(self) -> dict:
|
|
571
|
-
return self._rawGet("extradata")
|
|
572
|
-
|
|
573
559
|
@property
|
|
574
560
|
def teamtemplate(self) -> Optional["TeamTemplate"]:
|
|
575
|
-
if self.template
|
|
561
|
+
if self.template is None:
|
|
576
562
|
return None
|
|
577
563
|
return TeamTemplate(self._rawGet("teamtemplate"))
|
|
578
564
|
|
|
@@ -582,7 +568,6 @@ class MatchOpponent(LpdbBaseData):
|
|
|
582
568
|
|
|
583
569
|
|
|
584
570
|
class Placement(LpdbBaseResponseData):
|
|
585
|
-
|
|
586
571
|
@property
|
|
587
572
|
def tournament(self) -> str:
|
|
588
573
|
return self._rawGet("tournament")
|
|
@@ -693,7 +678,6 @@ class Placement(LpdbBaseResponseData):
|
|
|
693
678
|
|
|
694
679
|
|
|
695
680
|
class Player(LpdbBaseResponseData):
|
|
696
|
-
|
|
697
681
|
@property
|
|
698
682
|
def id(self) -> str:
|
|
699
683
|
return self._rawGet("id")
|
|
@@ -764,7 +748,6 @@ class Player(LpdbBaseResponseData):
|
|
|
764
748
|
|
|
765
749
|
|
|
766
750
|
class Series(LpdbBaseResponseData):
|
|
767
|
-
|
|
768
751
|
@property
|
|
769
752
|
def name(self) -> str:
|
|
770
753
|
return self._rawGet("name")
|
|
@@ -855,7 +838,6 @@ class Series(LpdbBaseResponseData):
|
|
|
855
838
|
|
|
856
839
|
|
|
857
840
|
class SquadPlayer(LpdbBaseResponseData):
|
|
858
|
-
|
|
859
841
|
@property
|
|
860
842
|
def id(self) -> str:
|
|
861
843
|
return self._rawGet("id")
|
|
@@ -926,7 +908,6 @@ class SquadPlayer(LpdbBaseResponseData):
|
|
|
926
908
|
|
|
927
909
|
|
|
928
910
|
class StandingsEntry(LpdbBaseResponseData):
|
|
929
|
-
|
|
930
911
|
@property
|
|
931
912
|
def parent(self) -> str:
|
|
932
913
|
return self._rawGet("parent")
|
|
@@ -981,7 +962,6 @@ class StandingsEntry(LpdbBaseResponseData):
|
|
|
981
962
|
|
|
982
963
|
|
|
983
964
|
class StandingsTable(LpdbBaseResponseData):
|
|
984
|
-
|
|
985
965
|
@property
|
|
986
966
|
def parent(self) -> str:
|
|
987
967
|
return self._rawGet("parent")
|
|
@@ -1016,7 +996,6 @@ class StandingsTable(LpdbBaseResponseData):
|
|
|
1016
996
|
|
|
1017
997
|
|
|
1018
998
|
class Team(LpdbBaseResponseData):
|
|
1019
|
-
|
|
1020
999
|
@property
|
|
1021
1000
|
def name(self) -> str:
|
|
1022
1001
|
return self._rawGet("name")
|
|
@@ -1083,7 +1062,6 @@ class Team(LpdbBaseResponseData):
|
|
|
1083
1062
|
|
|
1084
1063
|
|
|
1085
1064
|
class Tournament(LpdbBaseResponseData):
|
|
1086
|
-
|
|
1087
1065
|
@property
|
|
1088
1066
|
def name(self) -> str:
|
|
1089
1067
|
return self._rawGet("name")
|
|
@@ -1219,7 +1197,7 @@ class Tournament(LpdbBaseResponseData):
|
|
|
1219
1197
|
@property
|
|
1220
1198
|
def maps(self) -> list[str]:
|
|
1221
1199
|
map_data: Optional[str] = self._rawGet("maps")
|
|
1222
|
-
if map_data
|
|
1200
|
+
if map_data is None:
|
|
1223
1201
|
return None
|
|
1224
1202
|
return map_data.split(";")
|
|
1225
1203
|
|
|
@@ -1233,7 +1211,6 @@ class Tournament(LpdbBaseResponseData):
|
|
|
1233
1211
|
|
|
1234
1212
|
|
|
1235
1213
|
class Transfer(LpdbBaseResponseData):
|
|
1236
|
-
|
|
1237
1214
|
@property
|
|
1238
1215
|
def player(self) -> str:
|
|
1239
1216
|
return self._rawGet("player")
|
|
@@ -1280,7 +1257,6 @@ class Transfer(LpdbBaseResponseData):
|
|
|
1280
1257
|
|
|
1281
1258
|
|
|
1282
1259
|
class TeamTemplate(LpdbBaseData):
|
|
1283
|
-
|
|
1284
1260
|
@property
|
|
1285
1261
|
def template(self) -> str:
|
|
1286
1262
|
return self._rawGet("template")
|
|
@@ -15,11 +15,23 @@ from typing import (
|
|
|
15
15
|
)
|
|
16
16
|
import re
|
|
17
17
|
import warnings
|
|
18
|
+
import importlib.metadata as metadata
|
|
18
19
|
|
|
19
20
|
import requests
|
|
20
21
|
|
|
21
22
|
__all__ = ["LpdbDataType", "LpdbError", "LpdbWarning", "LpdbSession"]
|
|
22
23
|
|
|
24
|
+
_PACKAGE_NAME: Final[str] = "lpdb_python"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@cache
|
|
28
|
+
def _get_version() -> str:
|
|
29
|
+
try:
|
|
30
|
+
return metadata.version(_PACKAGE_NAME)
|
|
31
|
+
except metadata.PackageNotFoundError:
|
|
32
|
+
return "dev"
|
|
33
|
+
|
|
34
|
+
|
|
23
35
|
type LpdbDataType = Literal[
|
|
24
36
|
"broadcasters",
|
|
25
37
|
"company",
|
|
@@ -122,6 +134,7 @@ class AbstractLpdbSession(ABC):
|
|
|
122
134
|
"authorization": f"Apikey {self.__api_key}",
|
|
123
135
|
"accept": "application/json",
|
|
124
136
|
"accept-encoding": "gzip",
|
|
137
|
+
"user-agent": f"{_PACKAGE_NAME}/{_get_version()}",
|
|
125
138
|
}
|
|
126
139
|
|
|
127
140
|
@staticmethod
|
|
@@ -162,7 +175,7 @@ class AbstractLpdbSession(ABC):
|
|
|
162
175
|
:param order: the order of results to be sorted in; each ordering rule is specified as a `(datapoint, direction)` tuple
|
|
163
176
|
:param groupby: the way that the query results are grouped; each grouping rule is specified as a `(datapoint, direction)` tuple
|
|
164
177
|
|
|
165
|
-
:
|
|
178
|
+
:return: result of the query
|
|
166
179
|
|
|
167
180
|
:raises ValueError: if an invalid `lpdb_datatype` is supplied
|
|
168
181
|
:raises LpdbError: if something went wrong with the request
|
|
@@ -182,7 +195,7 @@ class AbstractLpdbSession(ABC):
|
|
|
182
195
|
:param wiki: the wiki to query
|
|
183
196
|
:param conditions: the conditions for the query
|
|
184
197
|
|
|
185
|
-
:
|
|
198
|
+
:return: number of objects that satisfy the condition(s)
|
|
186
199
|
|
|
187
200
|
:raises ValueError: if an invalid `lpdb_datatype` is supplied
|
|
188
201
|
:raises LpdbError: if something went wrong with the request
|
|
@@ -206,7 +219,7 @@ class AbstractLpdbSession(ABC):
|
|
|
206
219
|
:param template: the name of team template
|
|
207
220
|
:param date: the contextual date for the requested team template
|
|
208
221
|
|
|
209
|
-
:
|
|
222
|
+
:return: the requested team template, may return `None` if the requested team template does not exist
|
|
210
223
|
|
|
211
224
|
:raises LpdbError: if something went wrong with the request
|
|
212
225
|
"""
|
|
@@ -224,7 +237,7 @@ class AbstractLpdbSession(ABC):
|
|
|
224
237
|
:param wiki: the wiki to query
|
|
225
238
|
:param pagination: used for pagination
|
|
226
239
|
|
|
227
|
-
:
|
|
240
|
+
:return: team templates
|
|
228
241
|
|
|
229
242
|
:raises LpdbError: if something went wrong with the request
|
|
230
243
|
"""
|
|
@@ -250,21 +263,21 @@ class AbstractLpdbSession(ABC):
|
|
|
250
263
|
raise TypeError()
|
|
251
264
|
parameters["limit"] = min(limit, 1000)
|
|
252
265
|
parameters["offset"] = offset
|
|
253
|
-
if conditions
|
|
266
|
+
if conditions is not None:
|
|
254
267
|
parameters["conditions"] = conditions
|
|
255
|
-
if query
|
|
268
|
+
if query is not None:
|
|
256
269
|
if isinstance(query, str):
|
|
257
270
|
parameters["query"] = query
|
|
258
271
|
else:
|
|
259
272
|
parameters["query"] = ", ".join(query)
|
|
260
|
-
if order
|
|
273
|
+
if order is not None:
|
|
261
274
|
if isinstance(order, str):
|
|
262
275
|
parameters["order"] = order
|
|
263
276
|
else:
|
|
264
277
|
parameters["order"] = ", ".join(
|
|
265
278
|
[f"{order_tuple[0]} {order_tuple[1]}" for order_tuple in order]
|
|
266
279
|
)
|
|
267
|
-
if groupby
|
|
280
|
+
if groupby is not None:
|
|
268
281
|
if isinstance(groupby, str):
|
|
269
282
|
parameters["groupby"] = groupby
|
|
270
283
|
else:
|
|
@@ -361,7 +374,7 @@ class LpdbSession(AbstractLpdbSession):
|
|
|
361
374
|
"wiki": wiki,
|
|
362
375
|
"template": template,
|
|
363
376
|
}
|
|
364
|
-
if date
|
|
377
|
+
if date is not None:
|
|
365
378
|
params["date"] = date.isoformat()
|
|
366
379
|
lpdb_response = requests.get(
|
|
367
380
|
self._base_url + "teamtemplate",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lpdb_python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Author-email: ElectricalBoy <electricalboy01@gmail.com>
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Project-URL: Homepage, https://github.com/ElectricalBoy/LPDB_python
|
|
@@ -25,7 +25,21 @@ Dynamic: license-file
|
|
|
25
25
|
|
|
26
26
|
LPDB_python provides Python interfaces for the [Liquipedia Database API](https://liquipedia.net/api) (LPDB API).
|
|
27
27
|
|
|
28
|
-
##
|
|
28
|
+
## What You Need
|
|
29
|
+
|
|
30
|
+
- Python 3.12 or later
|
|
31
|
+
- API key for LPDB
|
|
32
|
+
- (Optional) [aiohttp](https://github.com/aio-libs/aiohttp)
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install lpdb_python
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Basic Uses
|
|
41
|
+
|
|
42
|
+
### LPDB Session
|
|
29
43
|
|
|
30
44
|
Python wrapper for LPDB session is defined in [session.py](src/lpdb_python/session.py). The wrapper provides the following
|
|
31
45
|
differences from making your own requests:
|
|
@@ -45,7 +59,16 @@ differences from making your own requests:
|
|
|
45
59
|
session = lpdb.LpdbSession("Apikey your_lpdb_api_key")
|
|
46
60
|
```
|
|
47
61
|
|
|
48
|
-
|
|
62
|
+
#### Async Session
|
|
63
|
+
|
|
64
|
+
Asynchronous implementation of LPDB session can be found in [async_session/session.py](src/lpdb_python/async_session/async_session.py).
|
|
65
|
+
This implementation depends on [aiohttp](https://github.com/aio-libs/aiohttp), which can be installed with this library with the following command:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install lpdb_python[async]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### LPDB Data Types
|
|
49
72
|
|
|
50
73
|
Data types in LPDB can be found in <https://liquipedia.net/commons/Help:LiquipediaDB>.
|
|
51
74
|
|
|
@@ -57,7 +80,7 @@ A property provided by the wrapper may be `None` if the raw data passed to the c
|
|
|
57
80
|
did not contain the data, or if it contained an empty string. Thus, the user should be checking for `None`
|
|
58
81
|
where appropriate.
|
|
59
82
|
|
|
60
|
-
|
|
83
|
+
#### Example
|
|
61
84
|
|
|
62
85
|
```python
|
|
63
86
|
import lpdb_python as lpdb
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
name: Publish
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
tags:
|
|
6
|
-
# Publish on any tag starting with a `v`, e.g., v0.1.0
|
|
7
|
-
- v*
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
run:
|
|
11
|
-
runs-on: ubuntu-latest
|
|
12
|
-
environment:
|
|
13
|
-
name: pypi
|
|
14
|
-
permissions:
|
|
15
|
-
id-token: write
|
|
16
|
-
contents: read
|
|
17
|
-
steps:
|
|
18
|
-
- name: Checkout
|
|
19
|
-
uses: actions/checkout@v6
|
|
20
|
-
|
|
21
|
-
- name: Setup Python
|
|
22
|
-
uses: actions/setup-python@v6
|
|
23
|
-
with:
|
|
24
|
-
python-version-file: "pyproject.toml"
|
|
25
|
-
|
|
26
|
-
- name: Install uv
|
|
27
|
-
uses: astral-sh/setup-uv@v7
|
|
28
|
-
|
|
29
|
-
- name: Build
|
|
30
|
-
run: uv build
|
|
31
|
-
|
|
32
|
-
- name: Publish
|
|
33
|
-
run: uv publish
|
|
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
|