Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elliot-100/spond-classes
Provides a class abstraction layer for the `Spond` library package.
https://github.com/elliot-100/spond-classes
abstraction-layer api-wrapper classes events python spond
Last synced: 2 months ago
JSON representation
Provides a class abstraction layer for the `Spond` library package.
- Host: GitHub
- URL: https://github.com/elliot-100/spond-classes
- Owner: elliot-100
- License: gpl-3.0
- Created: 2023-02-02T18:00:13.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-24T09:55:49.000Z (2 months ago)
- Last Synced: 2024-10-25T07:47:04.344Z (2 months ago)
- Topics: abstraction-layer, api-wrapper, classes, events, python, spond
- Language: Python
- Homepage:
- Size: 291 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Spond-classes
## About
[Spond](https://spond.com/welcome) is a team/group-oriented events system.
The unofficial Python [`spond` library package](https://github.com/Olen/Spond/) gets
data from the Spond API and returns `dict` objects.This unofficial Python `spond-classes` library package parses those `dict` objects to
create [Pydantic](https://docs.pydantic.dev/) class instances, i.e. provides an object abstraction layer.Experimental, partial, read-only implementation.
## Install
Install from PyPI, e.g:
```shell
pip install spond-classes
```
Or if you're using Poetry:
```shell
poetry add spond-classes
```
Note that [`spond`](https://github.com/Olen/Spond/) is required for practical use, but not a technical dependency,
so needs to be installed separately.## Example code
Adapting the example code in [`Spond`](https://github.com/Olen/Spond/) README:
```python
import asyncio
from spond.spond import Spond
from spond_classes import Group# fake credentials and ids
USERNAME = '[email protected]'
PASSWORD = 'Pa55worD'
GROUP_ID = 'G1'
SUBGROUP_ID = 'SG1'async def main():
s = Spond(username=USERNAME, password=PASSWORD)
group_data = await s.get_group(GROUP_ID)
await s.clientsession.close()# Now we can create a class instance ...
group = Group.model_validate(group_data)
# or `spond_classes.Group(**group_data)`# ... use class attributes instead of dict keys ...
print(group.name)# ... access subordinate instances and their attributes ...
for member in group.members:
print(f"{member.full_name} is in the {group.name} group")# ... and use some helper methods
subgroup = group.subgroup_by_id(SUBGROUP_ID)
for member in group.members_by_subgroup(subgroup):
print(f"{member.full_name} is in the {subgroup.name} subgroup")asyncio.run(main())
```
## DocumentationFull HTML documentation is available in the package source `docs` folder.
## Development
Generate documentation:
```shell
pdoc spond_classes -o docs -d numpy -t docs_templates
```