-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
757 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -201,4 +201,6 @@ atlassian-ide-plugin.xml | |
.idea/httpRequests | ||
|
||
.idea/dataSources.xml | ||
test.py | ||
test.py | ||
|
||
.ds_store |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Cache Configuration | ||
|
||
## Setting Expiry | ||
|
||
You can set the expiry time for requests when creating a client. The default expiry time is 30 minutes. | ||
|
||
The expiry time is in seconds. | ||
|
||
- `-1`: No expiry | ||
- `0`: Don't cache | ||
- *Any other number*: Cache for that many seconds | ||
|
||
```python | ||
import sendou | ||
import asyncio | ||
|
||
async def run(): | ||
client = sendou.Client("API_KEY", expiry=60) | ||
player = await client.get_user("USER_ID") | ||
print(player.name) | ||
|
||
asyncio.run(run()) | ||
``` | ||
|
||
## Advanced Configuration | ||
|
||
Caching in this module is handled by [aiohttp-client-cache](https://pypi.org/project/aiohttp-client-cache/). | ||
|
||
You can pass any aiohttp-client-cache CacheBackend to the client. | ||
Once you've instantiated the client by passing it through. | ||
|
||
You can see the full list of backends [here](https://aiohttp-client-cache.readthedocs.io/en/stable/backends.html). | ||
|
||
```python | ||
import sendou | ||
import asyncio | ||
from aiohttp_client_cache import SQLiteBackend | ||
|
||
async def run(): | ||
client = sendou.Client("API_KEY", expiry=60) | ||
client.cache = SQLiteBackend('demo_cache') | ||
player = await client.get_user("USER_ID") | ||
print(player.name) | ||
|
||
asyncio.run(run()) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Installation | ||
|
||
To install sendou.py, run the following command: | ||
|
||
```bash | ||
pip install sendou.py | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Usage Guide | ||
|
||
This quickstart assumes you know how to use AsyncIO and write asynchronous code in Python. | ||
|
||
## [Getting Player Info](../References/client.md#sendou.client.Client.get_tournament) | ||
|
||
```python | ||
from sendou import Client | ||
client = Client("API_KEY") | ||
player = await client.get_user("USER_ID") | ||
``` | ||
|
||
## [Getting Calendar Entries](../References/client.md#sendou.client.Client.get_calendar) | ||
|
||
```python | ||
from sendou import Client | ||
client = Client("API_KEY") | ||
tournament = await client.get_calendar("2023", "5") | ||
``` | ||
|
||
|
||
## [Getting Tournament Info](../References/client.md#sendou.client.Client.get_tournament) | ||
|
||
```python | ||
from sendou import Client | ||
client = Client("API_KEY") | ||
tournament = await client.get_tournament("TOURNAMENT_ID") | ||
``` | ||
|
||
### [Getting Tournament Teams](../References/models/tournament/tournament.md#sendou.models.tournament.tournament.Tournament.get_teams) | ||
|
||
```python | ||
from sendou import Client | ||
client = Client("API_KEY") | ||
tournament = await client.get_tournament("TOURNAMENT_ID") | ||
teams = await tournament.get_teams() | ||
``` | ||
|
||
### [Get Player from Team member](../References/models/tournament/team.md#sendou.models.tournament.team.TeamMember.get_user) | ||
|
||
```python | ||
from sendou import Client | ||
client = Client("API_KEY") | ||
tournament = await client.get_tournament("TOURNAMENT_ID") | ||
teams = await tournament.get_teams() | ||
for team in teams: | ||
for member in team.members: | ||
player = await member.get_player() | ||
``` | ||
|
||
### [Getting Tournament Bracket(s)](../References/models/tournament/tournament.md#sendou.models.tournament.tournament.TournamentBracket.get_bracket_data) | ||
|
||
```python | ||
from sendou import Client | ||
client = Client("API_KEY") | ||
tournament = await client.get_tournament("TOURNAMENT_ID") | ||
for bracket in tournament.brackets: | ||
bracket_data = await bracket.get_data() | ||
``` | ||
|
||
## [Getting Tournament Match Info](../References/client.md#sendou.client.Client.get_tournament_matches) | ||
**Note:** This is not linked to the bracket. You need to know the match ID. | ||
|
||
(*This will be updated in future when documentation is updated*) | ||
|
||
```python | ||
from sendou import Client | ||
client = Client("API_KEY") | ||
match = await client.get_tournament_matches("Match_ID") | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Sendou.py | ||
|
||
An async Python library for interacting with the [Sendou.ink](https://sendou.ink) API. | ||
|
||
**Not an official library!** | ||
|
||
This library is maintained by [Inkling Performance Labs Productions](https://github.com/iplsplatoon) | ||
|
||
## Dependencies | ||
- aiohttp | ||
- python-dateutil | ||
|
||
## Installation | ||
`pip install sendou.py` | ||
|
||
## Supported Endpoints | ||
- [x] Get user | ||
- [x] Get Tournament Info | ||
- [x] Get Tournament Teams | ||
- [X] Get Tournament Brackets | ||
- [x] Get Tournament Match Info (*by ID not linked to bracket*) | ||
|
||
## Usage | ||
```python | ||
import sendou | ||
import asyncio | ||
|
||
async def run(): | ||
client = sendou.Client("API_KEY") | ||
player = await client.get_user("USER_ID") | ||
print(player.name) | ||
|
||
asyncio.run(run()) | ||
``` | ||
|
||
## Getting an API Key | ||
To use this library, you must have an API key. You need to DM Sendou for an API Key currently. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
mkdocstrings[python] | ||
mkdocs-material | ||
mkdocs | ||
mkdocs-autorefs | ||
mkdocs-gen-files | ||
pymdown-extensions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
site_name: "sendou.py" | ||
repo_url: "https://github.com/IPLSplatoon/sendou.py" | ||
site_dir: "docs" | ||
|
||
plugins: | ||
- autorefs | ||
- search | ||
- gen-files: | ||
scripts: | ||
- scripts/genRefPages.py | ||
- mkdocstrings: | ||
handlers: | ||
python: | ||
options: | ||
docstring_style: google | ||
theme: | ||
name: material | ||
nav: | ||
- Overview: index.md | ||
- Getting Started: | ||
- Installation: getting-started/installation.md | ||
- Usage Guide: getting-started/usageGuide.md | ||
- Cache Configuration: cacheConfig.md | ||
palette: | ||
- media: "(prefers-color-scheme)" | ||
toggle: | ||
icon: material/brightness-auto | ||
name: Switch to light mode | ||
- media: "(prefers-color-scheme: light)" | ||
scheme: default | ||
primary: teal | ||
accent: purple | ||
toggle: | ||
icon: material/weather-sunny | ||
name: Switch to dark mode | ||
- media: "(prefers-color-scheme: dark)" | ||
scheme: slate | ||
primary: black | ||
accent: lime | ||
toggle: | ||
icon: material/weather-night | ||
name: Switch to system preference | ||
|
||
markdown_extensions: | ||
- attr_list | ||
- admonition | ||
- pymdownx.emoji: | ||
emoji_index: !!python/name:material.extensions.emoji.twemoji | ||
emoji_generator: !!python/name:material.extensions.emoji.to_svg | ||
- pymdownx.keys | ||
- pymdownx.magiclink | ||
- pymdownx.snippets: | ||
base_path: [!relative $config_dir] | ||
check_paths: true | ||
- pymdownx.superfences: | ||
custom_fences: | ||
- name: mermaid | ||
class: mermaid | ||
format: !!python/name:pymdownx.superfences.fence_code_format | ||
- pymdownx.tabbed: | ||
alternate_style: true | ||
slugify: !!python/object/apply:pymdownx.slugs.slugify | ||
kwds: | ||
case: lower | ||
- pymdownx.tasklist: | ||
custom_checkbox: true | ||
- toc: | ||
permalink: "¤" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from pathlib import Path | ||
import mkdocs_gen_files | ||
|
||
root = Path(__file__).parent.parent | ||
src = root / "sendou" | ||
|
||
|
||
for path in sorted(src.rglob("*.py")): | ||
module_path = path.relative_to(src).with_suffix("") | ||
if "__init__" in module_path.name: | ||
continue | ||
file_name_path = str(module_path).replace("/", ".") | ||
with mkdocs_gen_files.open(f"References/{str(module_path)}.md", "w") as fd: | ||
identifier = f"sendou.{file_name_path}" | ||
print("::: " + identifier, file=fd) |
Oops, something went wrong.