firmant.decorators

Decorators used throughout Firmant.

Functions

firmant.decorators.in_environment(key)

Assert that key is in the environment.

>>> @in_environment('somekey')
... def testfunc(environment):
...     print 'testfunc executes'
...
>>> inspect.getargspec(testfunc)
ArgSpec(args=['environment'], varargs=None, keywords=None, defaults=None)
>>> testfunc({'somekey': True})
testfunc executes
>>> testfunc(environment={'somekey': True})
testfunc executes
>>> testfunc({})
Traceback (most recent call last):
ValueError: Expected 'somekey' in 'environment'

The decorated function must take a non-keyword attribute for the environment.

>>> @in_environment('somekey')
... def testfunc():
...    print 'testfunc executes'
...
Traceback (most recent call last):
AttributeError: Decorated function must have arg 'environment'

Environment cannot have a default value.

>>> @in_environment('somekey')
... def testfunc(environment=None):
...    print 'testfunc executes'
...
Traceback (most recent call last):
AttributeError: Decorated function cannot have default value for 'environment'

Table Of Contents

Previous topic

firmant.chunks

Next topic

firmant.du

This Page