Experimental Python class abstraction layer for `spond` package.
Project description
Spond-classes
About
Spond is a team/group-oriented events system.
The unofficial Python spond
library package gets
data from the Spond API and returns dict
objects.
This unofficial Python spond-classes
package parses those dict
objects to create
class instances, i.e. provides an object abstraction layer.
Experimental, very partial, read-only implementation.
Install
Not yet available at PyPI. Install from GitHub:
pip install "Spond-classes @ git+https://github.com/elliot-100/spond-classes"
or for a specific version e.g:
pip install "Spond-classes @ git+https://github.com/elliot-100/spond-classes@v0.6.0"
If you're using Poetry:
poetry add git+https://github.com/elliot-100/spond-classes.git
or for a specific version:
poetry add git+https://github.com/elliot-100/spond-classes.git@v0.6.0
Key features
- Create
Group
class instance from the dict returned by the correspondingspond
method:
spond_classes.Group.from_dict()
- Then access class instance attributes and methods:
Group.uid: str
Group.name: str
Group.members: List[Member]
Group.member_by_id() -> Member
Group.roles: List[SpondRoles]
Group.role_by_id() -> Role
Group.subgroups: List[Subgroup]
Group.subgroup_by_id() -> Subgroup
- Also provides access to child instances -
Group
members, roles and subgroups:
Member.uid: str
Member.created_time: datetime
Member.first_name: str
Member.last_name: str
Member.full_name: str
Member.roles: List[Role]
Member.subgroups: List[Subgroup]
Role.uid: str
Role.members: List[Member]
Role.name: str
Subgroup.uid: str
Subgroup.members: List[Member]
Subgroup.name: str
- Create
Event
class instance from the dict returned by the correspondingSpond
method:
spond_classes.Event.from_dict()
- Then access attributes:
Event.uid: str
Event.heading: str
Event.start_time: datetime
Event.accepted_uids: list
Event.declined_uids: list
Event.unanswered_uids: list
Event.waiting_list_uids: list
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
README:
import asyncio
from spond import spond
import spond_classes
username = 'my@mail.invalid'
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())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for spond_classes-0.7.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49ae437a6122b5311bcd8b17fd531c75948728220c7c0525b347976b023254b9 |
|
MD5 | 5526ab49319544e9a6691e01fb57b2a9 |
|
BLAKE2b-256 | da7fd6e9501387616f5c1cbbc9fa2836760439bdbf66cd9ac324cd9f85235f93 |