5.3.1 draco.util -- Utility functions

The module draco.util contains some utility functions. These are used internally by Draco and they might or might not be helpful to you.

reval( expr)
Evaluate the Python expression expr in a restricuted execution environment. The result of the expression is returned.

reindent( s,[, indent=''][, strip=1])
Re-indent a multiline string. First, the indentation of s is stripped. The indentation level is determined by the first nonempty line in s, not taking into account the first line. If strip is nonzero, empty lines at the front and the end will be removed. If indent is specified, all lines but the first will be prepended with this string.

attributes( obj)
Return a dictionary containing the non-special attributes of the object obj. Special attributes starting with two underscores __ and are not added to the dictionary.

randInt( )
Returns a random integer, extraced from /dev/urandom. Draco uses this function to generate random session ids.

hiercmp( c1, c2)
Return -1 if c1 is a subclass of c2, +1 if c2 is a subclass of c1 or 0 otherwise. This function can be used to sort classes according to their heritage.

getBacktrace( )
Format a backtrace that indicates where the current exception has occurred. The backtrace is returned as a string.