-
-
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.
Merge pull request #28 from LEv145:dev
V0.4
- Loading branch information
Showing
34 changed files
with
1,002 additions
and
302 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 |
---|---|---|
|
@@ -10,3 +10,5 @@ exclude_lines = | |
if __name__ == .__main__.: | ||
pragma: no cover | ||
if TYPE_CHECKING: | ||
... | ||
pass |
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,2 @@ | ||
[flake8] | ||
max-line-length = 99 |
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,13 @@ | ||
|
||
# These are supported funding model platforms | ||
|
||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] | ||
patreon: lev145 | ||
open_collective: # Replace with a single Open Collective username | ||
ko_fi: # Replace with a single Ko-fi username | ||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
liberapay: # Replace with a single Liberapay username | ||
issuehunt: # Replace with a single IssueHunt username | ||
otechie: # Replace with a single Otechie username | ||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] |
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,25 @@ | ||
name: Python package | ||
|
||
on: | ||
- push | ||
- pull_request | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.8, 3.9, 3.10] | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install tox tox-gh-actions | ||
- name: Test with tox | ||
run: tox |
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 |
---|---|---|
@@ -1,5 +1,31 @@ | ||
|
||
.PHONY: build | ||
build: | ||
pip install --editable . | ||
|
||
|
||
.PHONY: binary | ||
binary: | ||
pyinstaller pyinstaller.spec --distpath pyinstaller_builds/linux_dist --workpath pyinstaller_builds/linux_build | ||
|
||
|
||
.PHONY: mkinit | ||
mkinit: | ||
mkinit sporepedia -w --black --nomods --relative --recursive | ||
|
||
|
||
.PHONY: run_tests | ||
run_tests: | ||
tox | ||
|
||
|
||
.PHONY: coverage_status | ||
coverage_status: | ||
coverage run -m unittest discover tests "test_*" | ||
coverage report -m | ||
|
||
|
||
.PHONY: clear | ||
clear: | ||
rm -R build/ dist/ .eggs/ pyinstaller_builds/ | ||
|
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 |
---|---|---|
@@ -1,2 +1,143 @@ | ||
# sporepedia.py | ||
Unofficial API client for sporepedia (https://www.spore.com/sporepedia) | ||
|
||
|
||
# How to use | ||
``` | ||
> sporepedia --help | ||
Usage: sporepedia [OPTIONS] COMMAND [ARGS]... | ||
CLI for sporepedia | ||
Options: | ||
--help Show this message and exit. | ||
Commands: | ||
search Search from sporepedia | ||
> sporepedia.exe search CAT --functions "is_civ_creature, is_adventure_creature, is_industry" --models "is_water" -F "most_popular_new" | ||
{"result_size": 363, "results": [...]} | ||
``` | ||
A simple and intuitive script, convenient output data in the form of json:3 | ||
(You can use a script from any programming language) | ||
|
||
# Build | ||
|
||
Build binary: | ||
``` | ||
pyinstaller pyinstaller.spec \ | ||
--distpath pyinstaller_builds/dist \ | ||
--workpath pyinstaller_builds/build | ||
``` | ||
Build for python (requires Python 3.7+) | ||
``` | ||
pip install --editable . | ||
``` | ||
|
||
# Work in Python | ||
### Install: | ||
``` | ||
pip install git+https://github.com/LEv145/sporepedia.py | ||
``` | ||
|
||
Client: | ||
```py | ||
import asyncio | ||
|
||
from sporepedia import ( | ||
SporepediaClient, | ||
SearchParams, | ||
FieldsSearchParam, | ||
FunctionsSearchParam, | ||
PurposesSearchParam, | ||
SearchFilter, | ||
) | ||
|
||
|
||
async def main() -> None: | ||
async with SporepediaClient() as client: | ||
result = await client.search( | ||
text="test", | ||
lenght=20, | ||
params=SearchParams( | ||
fields=FieldsSearchParam( | ||
is_name=True, | ||
is_author=True, | ||
is_tag=True, | ||
), | ||
functions=FunctionsSearchParam( | ||
is_tribe_creature=True, | ||
is_adventure_creature=True, | ||
is_industry=True, | ||
is_adv_collect=True, | ||
is_adv_puzzle=True, | ||
is_adv_template=True | ||
), | ||
purposes=PurposesSearchParam( | ||
is_military=True, | ||
is_cultural=True, | ||
), | ||
), | ||
filter=SearchFilter.featured, | ||
) | ||
print(result) # SearchServiceResult(result_size=48, results=[...]) | ||
|
||
|
||
asyncio.run(main()) | ||
``` | ||
Low level API (More options to customize!>3): | ||
```py | ||
import asyncio | ||
|
||
from sporepedia import ( | ||
APIClient, | ||
) | ||
|
||
|
||
async def main() -> None: | ||
async with APIClient() as client: | ||
result = await client.search( | ||
text="test", | ||
adv=1, | ||
batch_id=2, | ||
) | ||
print(result) # SearchServiceResult(result_size=48, results=[...]) | ||
|
||
|
||
asyncio.run(main()) | ||
``` | ||
|
||
|
||
# Coverage | ||
``` | ||
Name Stmts Miss Branch BrPart Cover Missing | ||
----------------------------------------------------------------------------------------------- | ||
sporepedia/__init__.py 0 0 0 0 100% | ||
sporepedia/__main__.py 0 0 0 0 100% | ||
sporepedia/api/__init__.py 0 0 0 0 100% | ||
sporepedia/api/client.py 0 0 0 0 100% | ||
sporepedia/api/methods/__init__.py 0 0 0 0 100% | ||
sporepedia/api/methods/dwr_parser.py 0 0 0 0 100% | ||
sporepedia/api/methods/mixin_protocol.py 0 0 0 0 100% | ||
sporepedia/api/methods/mixins/__init__.py 0 0 0 0 100% | ||
sporepedia/api/methods/mixins/search/__init__.py 0 0 0 0 100% | ||
sporepedia/api/methods/mixins/search/builders.py 0 0 0 0 100% | ||
sporepedia/api/methods/mixins/search/composers.py 0 0 0 0 100% | ||
sporepedia/api/methods/mixins/search/methods.py 0 0 0 0 100% | ||
sporepedia/api/methods/mixins/search/models.py 0 0 0 0 100% | ||
sporepedia/client.py 0 0 0 0 100% | ||
tests/test_api.py 0 0 0 0 100% | ||
tests/test_cli.py 0 0 0 0 100% | ||
tests/test_client.py 0 0 0 0 100% | ||
tests/test_dwr_parser.py 0 0 0 0 100% | ||
tests/test_search.py 0 0 0 0 100% | ||
----------------------------------------------------------------------------------------------- | ||
TOTAL 0 0 0 0 100% | ||
``` | ||
|
||
TODO: | ||
- [ ] Autotest from git (Tox) | ||
- [x] 100% tests | ||
- [x] Cli client | ||
- [ ] Docs | ||
- [ ] New methods |
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 @@ | ||
[mypy] | ||
ignore_missing_imports = True | ||
strict_optional = True | ||
implicit_reexport = True | ||
warn_unused_ignores = False | ||
disallow_any_generics = False |
Oops, something went wrong.