kuai package

Submodules

kuai.helpers module

Various helper functions for Kuai, these are all from stackoverflow. Amen.

class kuai.helpers.Singleton[source]

Bases: type

Metaclass for singleton objects. Any instantiation of a Singleton class yields the exact same object, e.g.:

>>> class MyClass(metaclass=Singleton):
        pass
>>> a = MyClass()
>>> b = MyClass()
>>> a is b
True
class kuai.helpers.WeakCallback(callback)[source]

Bases: object

A Weak Callback object that will keep a reference to the connecting object with weakref semantics.

This allows object A to pass a callback method to object S, without object S keeping A alive. **Extended to work with unbound calls, ie: functions, lambdas..

kuai.helpers.singleton_object(cls)[source]

Class decorator that transforms (and replaces) a class definition (which must have a Singleton metaclass) with the actual singleton object. Ensures that the resulting object can still be “instantiated” (i.e., called), returning the same object. Also ensures the object can be pickled, is hashable, and has the correct string representation (the name of the singleton)

Module contents

kuai.kuai_backend()[source]
kuai.set_backend(name)[source]