API

drypy

The package provides some basic function to turn on/off the dryrun mode.

drypy - dryrun for python

drypy.dryrun(state=None)

Return current dryrun mode, If state is provided activate/deactivate dryrun before returning the status

Optional args:

state (bool): Set dryrun mode to the desired state.

Returns:

bool

drypy.get_status()

Returns True if the dryrun system is active.

Returns:

True or False

drypy.set_dryrun(value)

Set the dryrun mode on or off.

Args:

value (bool): Mode to be in.

drypy.toggle_dryrun()

Toggle the current dryrun mode.

patterns.py

This module provide the decorators to mark your own function you want to dryrun.

drypy.patterns.sham(func)

Decorator which makes drypy to log the call of the target function without executing it.

Example:
>>> @sham
... def foo(bar, baz=None):
...     return 42
...
>>> foo("sport", baz=False)
42
>>> foo("sport", baz=False)
INFO:drypy.sham:[DRYRUN] call to 'foo(sport, baz=False)'
drypy.patterns.sheriff(func)

Decorator which makes drypy to run func.deputy instead of func.

Example:
>>> @sheriff
... def woody():
...    print("I'm the Sheriff!")
...
>>> @woody.deputy
... def woody():
...    print("I'm the Deputy!")
...
...
>>> woody()
I'm the Sheriff!
>>> drypy.set_dryrun(True)
>>> woody()
I'm the Deputy!