util¶
util
¶
Module for utility functions and classes used throughout the package.
Patch
¶
Class representing a replacement of an attribute on a module.
| ATTRIBUTE | DESCRIPTION |
|---|---|
obj |
Object to replace.
TYPE:
|
replacement |
Object that replaces.
TYPE:
|
parent |
Module or class to replace attribute.
TYPE:
|
restore
¶
Carries out the restoration of the original object on the objects module/class.
Patcher
¶
Patcher(patches: Optional[List[Patch]] = None)
Bases: AbstractContextManager
Context manager that patches from a list of Patches on enter and restores the patch on exit.
| ATTRIBUTE | DESCRIPTION |
|---|---|
patches |
TYPE:
|
apply
¶
Applies some function to all members of a collection of a give type (or types)
| PARAMETER | DESCRIPTION |
|---|---|
data
|
Collection of data to apply function to.
TYPE:
|
fn
|
Function to apply.
TYPE:
|
cls
|
Type or Types to apply function to.
TYPE:
|
inplace
|
If to apply the fn inplace. (For lists and dicts)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Any
|
Same kind of collection as data, after then fn has been applied to members of given type.
TYPE:
|
applyn
¶
Applies some function to all members of a collection of a give type (or types)
| PARAMETER | DESCRIPTION |
|---|---|
data
|
Collection of data to apply function to.
TYPE:
|
fn
|
Function to apply.
TYPE:
|
cls
|
Type or Types to apply function to.
TYPE:
|
inplace
|
If to apply the fn inplace. (For lists and dicts)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Any
|
Same kind of collection as data, after then fn has been applied to members of given type.
TYPE:
|
fetch_attr
¶
Retrieves an attribute from an object hierarchy given an attribute path. Levels are separated by '.' e.x (transformer.h.1)
| PARAMETER | DESCRIPTION |
|---|---|
object
|
Root object to get attribute from.
TYPE:
|
target
|
Attribute path as '.' separated string.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Any
|
Fetched attribute.
TYPE:
|