Decorators¶
patch |
Decorator to create a patch. |
patches |
Decorator to create a patch for each member of a module or a class. |
destination |
Modifier decorator to update a patch’s destination. |
name |
Modifier decorator to update a patch’s name. |
settings |
Modifier decorator to update a patch’s settings. |
filter |
Modifier decorator to force the inclusion or exclusion of an attribute. |
-
gorilla.
patch
(destination, name=None, settings=None)[source]¶ Decorator to create a patch.
The object being decorated becomes the
obj
attribute of the patch.Parameters: - destination (object) – Patch destination.
- name (str) – Name of the attribute at the destination.
- settings (gorilla.Settings) – Settings.
Returns: The decorated object.
Return type: object
See also
-
gorilla.
patches
(destination, settings=None, traverse_bases=True, filter=<function default_filter>, recursive=True, use_decorators=True)[source]¶ Decorator to create a patch for each member of a module or a class.
Parameters: - destination (object) – Patch destination.
- settings (gorilla.Settings) – Settings.
- traverse_bases (bool) – If the object is a class, the base classes are also traversed.
- filter (function) – Attributes for which the function returns
False
are skipped. The function needs to define two parameters:name
, the attribute name, andobj
, the attribute value. IfNone
, no attribute is skipped. - recursive (bool) – If
True
, and a hit occurs due to an attribute at the destination already existing with the given name, and both the member and the target attributes are classes, then instead of creating a patch directly with the member attribute value as is, a patch for each of its own members is created with the target as new destination. - use_decorators (bool) – Allows to take any modifier decorator into consideration to allow for more granular customizations.
Returns: The decorated object.
Return type: object
Note
A ‘target’ differs from a ‘destination’ in that a target represents an existing attribute at the destination about to be hit by a patch.
See also
-
gorilla.
destination
(value)[source]¶ Modifier decorator to update a patch’s destination.
This only modifies the behaviour of the
create_patches()
function and thepatches()
decorator, given that their parameteruse_decorators
is set toTrue
.Parameters: value (object) – Patch destination. Returns: The decorated object. Return type: object
-
gorilla.
name
(value)[source]¶ Modifier decorator to update a patch’s name.
This only modifies the behaviour of the
create_patches()
function and thepatches()
decorator, given that their parameteruse_decorators
is set toTrue
.Parameters: value (object) – Patch name. Returns: The decorated object. Return type: object
-
gorilla.
settings
(**kwargs)[source]¶ Modifier decorator to update a patch’s settings.
This only modifies the behaviour of the
create_patches()
function and thepatches()
decorator, given that their parameteruse_decorators
is set toTrue
.Parameters: kwargs – Settings to update. See Settings
for the list.Returns: The decorated object. Return type: object
-
gorilla.
filter
(value)[source]¶ Modifier decorator to force the inclusion or exclusion of an attribute.
This only modifies the behaviour of the
create_patches()
function and thepatches()
decorator, given that their parameteruse_decorators
is set toTrue
.Parameters: value (bool) – True
to force inclusion,False
to force exclusion, andNone
to inherit from the behaviour defined bycreate_patches()
orpatches()
.Returns: The decorated object. Return type: object