API Reference

Model

>>> from uiclasses import Model
>>>
>>> class User(Model):
...     email: str
...
class uiclasses.Model(__data__: dict = None, *args, **kw)[source]

Base class for User-interface classes.

Allows declaring what instance attributes are visible via type annotations or __visible_attributes__.

Example:

from uiclasses.base import Model

class BlogPost(Model):
    id: int
    title: str


 post = BlogPost(
     id=1,
     title='test',
     body='lorem ipsum dolor sit amet'
 )

 print(str(post))
 print(repr(post))
 print(post.format_robust_table())

Model.List

>>> user1 = User(email="aaaa@test.com")
>>> user2 = User(email="bbbb@test.com")
>>>
>>> users = User.List([user1, user2, user1])
>>> users
User.List[user1, user2, user3]
class uiclasses.collections.ModelList(children: Iterable[uiclasses.base.Model])[source]

Implementation of IterableCollection for the list type.

Model.Set

An ordered set for managing unique items.

>>> user1 = User(email="aaaa@test.com")
>>> user2 = User(email="bbbb@test.com")
>>>
>>> users = User.Set([user1, user2, user1])
>>> users
User.Set[user1, user2]
class uiclasses.collections.ModelSet(*args, **kwds)[source]

Implementation of IterableCollection for the OrderedSet type.

DataBag

class uiclasses.DataBag(__data__: dict = None)[source]

base-class for config containers, behaves like a dictionary but is a enhanced proxy to manage data from its internal dict __data__ as well as traversing nested dictionaries within it.

UserFriendlyObject

class uiclasses.UserFriendlyObject[source]

DataBagChild

class uiclasses.DataBagChild(data, *location)[source]

Represents a nested dict within a DataBag that is aware of its location within the parent.

IterableCollection

class uiclasses.collections.IterableCollection[source]

Base mixin for ModelList and ModelSet, provides methods to manipulate iterable collections in ways take advantage of the behavior of models.

For example it supports filtering by instance attributes through a cal to the attribute_matches() method of each children.

Features:

  • sorted_by() - sort by a single attribute

  • filter_by() - to filter by a single attribute

  • sorted() - alias to MyModel.List(sorted(my_model_collection)) or .Set()

  • filter() - alias to MyModel.List(filter(callback, my_model_collection))

  • format_robust_table()

  • format_pretty_table()

Utils

File-System Helpers

runtime helper functions used for leveraging idiosyncrasies of testing.

Meta