-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump version to 0.8.1; update CHANGELOG for new version; README reorder
- Loading branch information
1 parent
5efbba1
commit 2436f1e
Showing
3 changed files
with
35 additions
and
33 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
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 |
---|---|---|
|
@@ -23,6 +23,36 @@ Or if you're using Poetry: | |
poetry add spond-classes | ||
` | ||
|
||
## Example code | ||
|
||
Adapting the example code in [`Spond`](https://github.com/Olen/Spond/) README: | ||
|
||
``` | ||
import asyncio | ||
from spond import spond | ||
import spond_classes | ||
username = '[email protected]' | ||
password = 'Pa55worD' | ||
group_id = 'C9DC791FFE63D7914D6952BE10D97B46' # fake | ||
async def main(): | ||
s = spond.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 = spond_classes.Group.from_dict(group_data) | ||
# ... use class properties instead of dict keys ... | ||
print(group.name) | ||
# ... and access child instances and their properties | ||
for member in group.members: | ||
print(member.full_name) | ||
asyncio.run(main()) | ||
``` | ||
## Key features | ||
|
||
* Create `Group` class instance from the dict returned by the corresponding `spond` | ||
|
@@ -89,34 +119,3 @@ Event.unconfirmed_uids: list | |
|
||
It's also possible to create `Member.from_dict()`, `Role.from_dict()`, | ||
`Subgroup.from_dict()`. | ||
|
||
## Example code | ||
|
||
Adapting the example code in [`Spond`](https://github.com/Olen/Spond/) README: | ||
|
||
``` | ||
import asyncio | ||
from spond import spond | ||
import spond_classes | ||
username = '[email protected]' | ||
password = 'Pa55worD' | ||
group_id = 'C9DC791FFE63D7914D6952BE10D97B46' # fake | ||
async def main(): | ||
s = spond.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 = spond_classes.Group.from_dict(group_data) | ||
# ... use class properties instead of dict keys ... | ||
print(group.name) | ||
# ... and access child instances and their properties | ||
for member in group.members: | ||
print(member.full_name) | ||
asyncio.run(main()) | ||
``` |
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,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "spond-classes" | ||
version = "0.8.0" | ||
version = "0.8.1" | ||
description = "Experimental Python class abstraction layer for `spond` package." | ||
authors = ["elliot-100 <[email protected]>"] | ||
readme = "README.md" | ||
|