cb
—callback management¶
-
takes_args
(func)[source]¶ Determine whether the given function takes any arguments.
Returns: True
if the function can take arguments, or if the result could not be determined (the argument is not a function, or not a pure-Python function), elseFalse
.
-
wrap_fn
(func) → wrapper[source]¶ Return a function that calls
func
, possibly omitting arguments.When
wrapper
is called, it callsfunc
(and returns its return value), but only passes any arguments on tofunc
if it is determined thatfunc
takes any arguments (usingtakes_args()
).
-
class
CbManager
[source]¶ Bases:
object
Simple callback manager.
-
cbs
¶ Set-like container of registered callback functions.
-
-
class
GroupedCbManager
([groups])[source]¶ Bases:
object
Manage callbacks grouped by type.
Parameters: groups – allowed groups; overrides the class’s default groups
.A group identifier may be hashable object. Groups are equivalent if they produce the same hash value.
-
groups
= frozenset([])¶ Set of groups available to place callbacks in. If methods are given any other group identifier not in here,
ValueError
is raised.
-
cbs
¶ Registered callback functions, as
{group: callbacks}
.
-
cb
(group, *cbs) → self[source]¶ Register callbacks for a group.
If a callback is determined not to be able to take arguments, it is not passed any.
-