NiBabel

Access a cacophony of neuro-imaging file formats

Table Of Contents

Previous topic

tmpdirs

Next topic

wrapstruct

Reggie -- the one

tripwire

Class to raise error for missing modules or other misfortunes

TripWire(msg) Class raising error if used
TripWireError Exception if trying to use TripWire object
is_tripwire(obj) Returns True if obj appears to be a TripWire object

TripWire

class nibabel.tripwire.TripWire(msg)

Bases: object

Class raising error if used

Standard use is to proxy modules that we could not import

Examples

>>> try:
...     import silly_module_name
... except ImportError:
...    silly_module_name = TripWire('We do not have silly_module_name')
>>> silly_module_name.do_silly_thing('with silly string') 
Traceback (most recent call last):
    ...
TripWireError: We do not have silly_module_name
Traceback (most recent call last):
    ...
TripWireError: We do not have silly_module_name
__init__(msg)

TripWireError

class nibabel.tripwire.TripWireError

Bases: exceptions.Exception

Exception if trying to use TripWire object

__init__()

x.__init__(...) initializes x; see help(type(x)) for signature

is_tripwire

nibabel.tripwire.is_tripwire(obj)

Returns True if obj appears to be a TripWire object

Examples

>>> is_tripwire(object())
False
>>> is_tripwire(TripWire('some message'))
True