Skip to content

Provides a class abstraction layer for the `Spond` library package.

License

Notifications You must be signed in to change notification settings

Olen/Spond-classes

 
 

Repository files navigation

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 library package parses those dict objects to create Pydantic class instances, i.e. provides an object abstraction layer.

Experimental, partial, read-only implementation.

Install

Install from PyPI, e.g:

pip install spond-classes

Or if you're using Poetry:

poetry add spond-classes

Note that 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 README:

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())

Documentation

Full HTML documentation is available in the package source docs folder.

Development

Generate documentation:

pdoc spond_classes -o docs -d numpy -t docs_templates

About

Provides a class abstraction layer for the `Spond` library package.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.0%
  • Jinja 1.0%