Skip to content

Commit 6b3b2c9

Browse files
authored
Merge pull request #62 from LEv145:dev
V 1.0
2 parents 634147e + 03ab463 commit 6b3b2c9

File tree

6 files changed

+83
-25
lines changed

6 files changed

+83
-25
lines changed

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
venv
21
.*
32
__pycache__
43
test.py
54
dist
65
spore.py.egg-info
76
static_tests
8-
.pyinstaller_*
7+
venv*
8+
pyinstaller_builds

Makefile

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
MAKEDIR = pyinstaller_builds
2+
3+
14
.PHONY: build
25
build:
6+
pip install --editable .
7+
8+
.PHONY: binary
9+
binary:
310
pyinstaller pyinstaller.spec \
4-
--distpath .pyinstaller_dist \
5-
--workpath .pyinstaller_build
11+
--distpath pyinstaller_builds/linux_dist \
12+
--workpath pyinstaller_builds/linux_build
613

714
.PHONY: clean
815
clean:
9-
rm .pyinstaller_*
16+
rm -R pyinstaller_builds

README.md

+55-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,65 @@
11
# Spore REST API asyncio client
22
* Python 3.7+
33

4+
# How to use
5+
```
6+
> spore_cli.exe --help
7+
Usage: spore_cli [OPTIONS] COMMAND [ARGS]...
8+
9+
CLI for Spore REST API
10+
11+
Options:
12+
--help Show this message and exit.
13+
14+
Commands:
15+
get-asset-comments Get comments of the asset
16+
get-asset-info Get asset information
17+
get-creature Get creature
18+
get-sporecast-assets Get assets of the sporecast
19+
get-stats Get stats
20+
get-user-achievements Get achievements of the user
21+
get-user-assets Get creature of the user
22+
get-user-buddies Get buddies of the user
23+
get-user-info Get user information
24+
get-user-sporecasts Get sporecasts of the user
25+
get-user-subscribers Get subscribers of the user
26+
search-assets Search assets
27+
28+
> spore_cli.exe search-assets --help
29+
Usage: spore_cli search-assets [OPTIONS] {top_rated|top_rated_new|newest|featu
30+
red|maxis_made|random|cute_and_creepy}
31+
[START_INDEX] [LENGTH]
32+
[[building|creature|vehicle|adventure|ufo]]
33+
34+
Search assets
35+
36+
Options:
37+
--help Show this message and exit.
38+
39+
> spore_cli.exe get-creature 500267423060 # Get json info of creature
40+
{"asset_id": 500267423060, "cost": 4065, "health": 3.0, "height": 1.3428643, "meanness": 9.0, "cuteness": 71.26385, "sense": 1.0, "bonecount": 44.0, "footcount": 4.0, "graspercount": 0.0, "basegear": 0.0, "carnivore": 1.0, "herbivore": 0.0, "glide": 0.0, "sprint": 2.0, "stealth": 2.0, "bite": 3.0, "charge": 2.0, "strike": 4.0, "spit": 0.0, "sing": 1.0, "dance": 2.0, "gesture": 5.0, "posture": 0.0}
41+
```
42+
43+
# Build
44+
## Linux
45+
Build binary:
46+
```
47+
make binary
48+
```
449

5-
**Install:**
50+
Build for python
51+
```
52+
make build
53+
```
54+
55+
# Work in Python
56+
57+
## Install:
658
```py
759
pip install git+https://github.com/LEv145/spore.py
860
```
961

10-
11-
**Simple examples:**
62+
## Simple examples
1263
```py
1364
import asyncio
1465

@@ -46,7 +97,7 @@ def main() -> None:
4697
main()
4798
```
4899

49-
**Client methods:**
100+
## Client methods
50101

51102
```py
52103
get_stats() -> Stats

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
},
2626
entry_points="""
2727
[console_scripts]
28-
spore=spore_api.scripts.spore_cli:cli
28+
spore_cli=spore_api.__main__:cli
2929
"""
3030
)

spore_api/__main__.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ async def cli():
1515
"""CLI for Spore REST API"""
1616

1717

18-
@cli.command()
18+
@cli.command(help="Get stats")
1919
async def get_stats():
2020
async with _client as client:
2121
result = await client.get_stats()
2222
click.echo(result.to_json())
2323

2424

25-
@cli.command()
25+
@cli.command(help="Get creature")
2626
@click.argument("asset_id", type=int)
2727
async def get_creature(asset_id: int):
2828
async with _client as client:
@@ -32,7 +32,7 @@ async def get_creature(asset_id: int):
3232
click.echo(result.to_json())
3333

3434

35-
@cli.command()
35+
@cli.command(help="Get user information")
3636
@click.argument("username", type=str)
3737
async def get_user_info(username: str):
3838
async with _client as client:
@@ -42,7 +42,7 @@ async def get_user_info(username: str):
4242
click.echo(result.to_json())
4343

4444

45-
@cli.command()
45+
@cli.command(help="Get creature of the user")
4646
@click.argument("username", type=str)
4747
@click.argument("start_index", type=int, default=1)
4848
@click.argument("length", type=int, default=10)
@@ -56,7 +56,7 @@ async def get_user_assets(username: str, start_index: int, length: int):
5656
click.echo(result.to_json())
5757

5858

59-
@cli.command()
59+
@cli.command(help="Get sporecasts of the user")
6060
@click.argument("username", type=str)
6161
async def get_user_sporecasts(username: str):
6262
async with _client as client:
@@ -66,7 +66,7 @@ async def get_user_sporecasts(username: str):
6666
click.echo(result.to_json())
6767

6868

69-
@cli.command()
69+
@cli.command(help="Get achievements of the user")
7070
@click.argument("username", type=str)
7171
@click.argument("start_index", type=int, default=1)
7272
@click.argument("length", type=int, default=10)
@@ -80,7 +80,7 @@ async def get_user_achievements(username: str, start_index: int, length: int):
8080
click.echo(result.to_json())
8181

8282

83-
@cli.command()
83+
@cli.command(help="Get buddies of the user")
8484
@click.argument("username", type=str)
8585
@click.argument("start_index", type=int, default=1)
8686
@click.argument("length", type=int, default=10)
@@ -94,7 +94,7 @@ async def get_user_buddies(username: str, start_index: int, length: int):
9494
click.echo(result.to_json())
9595

9696

97-
@cli.command()
97+
@cli.command(help="Get subscribers of the user")
9898
@click.argument("username", type=str)
9999
@click.argument("start_index", type=int, default=1)
100100
@click.argument("length", type=int, default=10)
@@ -108,7 +108,7 @@ async def get_user_subscribers(username: str, start_index: int, length: int):
108108
click.echo(result.to_json())
109109

110110

111-
@cli.command()
111+
@cli.command(help="Get asset information")
112112
@click.argument("asset_id", type=int)
113113
async def get_asset_info(asset_id: int):
114114
async with _client as client:
@@ -118,7 +118,7 @@ async def get_asset_info(asset_id: int):
118118
click.echo(result.to_json())
119119

120120

121-
@cli.command()
121+
@cli.command(help="Get comments of the asset")
122122
@click.argument("asset_id", type=int)
123123
@click.argument("start_index", type=int, default=1)
124124
@click.argument("length", type=int, default=10)
@@ -132,7 +132,7 @@ async def get_asset_comments(asset_id: int, start_index: int, length: int):
132132
click.echo(result.to_json())
133133

134134

135-
@cli.command()
135+
@cli.command(help="Get assets of the sporecast")
136136
@click.argument("sporecast_id", type=int)
137137
@click.argument("start_index", type=int, default=1)
138138
@click.argument("length", type=int, default=10)
@@ -146,7 +146,7 @@ async def get_sporecast_assets(sporecast_id: int, start_index: int, length: int)
146146
click.echo(result.to_json())
147147

148148

149-
@cli.command()
149+
@cli.command(help="Search assets")
150150
@click.argument(
151151
"view_type",
152152
type=click.Choice(ViewType._member_names_, case_sensitive=False)
@@ -158,9 +158,9 @@ async def get_sporecast_assets(sporecast_id: int, start_index: int, length: int)
158158
type=click.Choice(AssetType._member_names_, case_sensitive=False),
159159
required=False
160160
)
161-
async def assets_search(view_type: str, start_index: int, length: int, asset_type: Optional[str]):
161+
async def search_assets(view_type: str, start_index: int, length: int, asset_type: Optional[str]):
162162
async with _client as client:
163-
result = await client.assets_search(
163+
result = await client.search_assets(
164164
view_type=ViewType[view_type],
165165
start_index=start_index,
166166
length=length,

spore_api/client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ async def get_user_subscribers(
181181
)
182182
)
183183

184-
async def assets_search(
184+
async def search_assets(
185185
self,
186186
view_type: ViewType,
187187
start_index: Union[int, str],

0 commit comments

Comments
 (0)