SAFplus Runtime Director API  3.0.5
misc Namespace Reference

Miscellaneous routines including logging, pretty printers, and enhanced functionality wrappers for some standard library type functions. More...

Classes

class  Error
 Base error object for the asppybinding library. More...
 
class  Unimplemented
 An exception that indicates functionality is not ready. More...
 
class  TODO
 An exception that indicates there is more work to be done here. More...
 

Functions

def ArdVersion
 
def yesNo2Bool
 Convert a string to a boolean. More...
 
def duration2ms
 Converts a string describing a time interval in a number of milliseconds. More...
 
def List2Str
 Helper function that converts a list to a comma separated string. More...
 
def Sort
 Helper function that does a inplace sort inline (i.e. More...
 
def Tenglish
 Default english internationalization substitution function (there's nothing to do) More...
 
def setT
 Set the default translation function. More...
 
def T
 Call this function to do a translation. More...
 
def Implements
 Returns True if the object implements (is or is derived from) a class. More...
 
def systemDetailed
 Similar to the os.system call, except that a lot more information is returned. More...
 
def system
 Similar to the os.system call, except that the return value, signal status and core will cause an exception to be raised. More...
 
def thisLine
 Return line number of the nth caller (caller's caller, etc) based on the back argument. More...
 
def thisFile
 Return file of the nth caller (caller's caller, etc) based on the back argument. More...
 
def flatten
 Turn a list of list of lists,etc into just 1 list. More...
 
def Tagify
 Turn a string into something that can be used as an XML attribute. More...
 
def ziprepeat
 Does a python "zip" but repeats ylst over again if it is too short. More...
 

Variables

 ContextUndefined = None
 Undefined error context. More...
 
string ContextProgramReturnCode = "program return code"
 The exception code is a program's return code. More...
 
string ContextErrno = "errno"
 The exception code is an errno (see errno.h system header file) More...
 
string ContextSignal = "signal"
 The exception code is a signal (see signal.h system header file. More...
 
tuple lcl = threading.local()
 

Detailed Description

Miscellaneous routines including logging, pretty printers, and enhanced functionality wrappers for some standard library type functions.

Function Documentation

def misc.ArdVersion ( )
def misc.duration2ms (   t)

Converts a string describing a time interval in a number of milliseconds.

The string can have the format '# unit'. (ex: 5 sec). If no unit is specified, milliseconds is assumed Acceptable units are all case or plural variations of week day hour hr min sec ms millisec

Parameters
tA time interval Can be an integer, float or string.
def misc.flatten (   listOflists)

Turn a list of list of lists,etc into just 1 list.

flatten([1,2,[3,4],[5,[6],7,[]]]) -> [1, 2, 3, 4, 5, 6, 7]

def misc.Implements (   obj,
  typ 
)

Returns True if the object implements (is or is derived from) a class.

Parameters
objThe object in question
typThe class type in question
Returns
boolean
def misc.List2Str (   lst)

Helper function that converts a list to a comma separated string.

def misc.setT (   fn)

Set the default translation function.

Parameters
fnThe translation function to be used. Here is a template:
1 def Tenglish(s,**kw):
2  return Template(str(s)).substitute(**kw)
def misc.Sort (   x)

Helper function that does a inplace sort inline (i.e.

x is returned). This is convenient for use in web template files. Note that a copy is NOT made. This function modifies its parameter!

Parameters
xcontainer to be sorted
Returns
x
def misc.system (   cmd)

Similar to the os.system call, except that the return value, signal status and core will cause an exception to be raised.

def misc.systemDetailed (   cmd)

Similar to the os.system call, except that a lot more information is returned.

Parameters
cmdA string containing the command you want to run
Returns
(retval, output, signal, core) retval The program return code output The program's stdout signal Did any signal cause it to die? core Was a core file generated?
def misc.T (   s,
  kw 
)

Call this function to do a translation.

Parameters
def misc.Tagify (   s)

Turn a string into something that can be used as an XML attribute.

def misc.Tenglish (   s,
  kw 
)

Default english internationalization substitution function (there's nothing to do)

def misc.thisFile (   back = 0)

Return file of the nth caller (caller's caller, etc) based on the back argument.

Parameters
backHow far to unwind the stack. 0 means the caller, 1 is the caller's caller, etc.
def misc.thisLine (   back = 0)

Return line number of the nth caller (caller's caller, etc) based on the back argument.

Parameters
backHow far to unwind the stack. 0 means the caller, 1 is the caller's caller, etc.
def misc.yesNo2Bool (   yn)

Convert a string to a boolean.

If yn is a string, this routine will attempt to convert all case variations of "true", "yes", "y" or "1" to True and all variations of "false", "no" "n" or "0" to False. If yn is not a string, it will be cast to a boolean and returned.

Parameters
ynstring to convert
def misc.ziprepeat (   xlst,
  ylst 
)

Does a python "zip" but repeats ylst over again if it is too short.

Variable Documentation

misc.ContextErrno = "errno"

The exception code is an errno (see errno.h system header file)

misc.ContextProgramReturnCode = "program return code"

The exception code is a program's return code.

misc.ContextSignal = "signal"

The exception code is a signal (see signal.h system header file.

misc.ContextUndefined = None

Undefined error context.

tuple misc.lcl = threading.local()