6.26. foundations.trace

trace.py

Platform:
Windows, Linux, Mac Os X.
Description:
Defines Foundations package trace objects.
Others:
Portions of the code from echo.py by Thomas Guest: http://wordaligned.org/svn/etc/echo/echo.py.

6.26.1. Module Attributes

foundations.trace.REGISTERED_MODULES
foundations.trace.TRACER_SYMBOL
foundations.trace.UNTRACABLE_SYMBOL
foundations.trace.TRACER_HOOK
foundations.trace.UNTRACABLE_NAMES
foundations.trace.NULL_OBJECT_NAME
foundations.trace.TRACE_NAMES_CACHE
foundations.trace.TRACE_WALKER_CACHE

6.26.2. Functions

foundations.trace.isReadOnly(object)[source]

Returns if given object is read only ( built-in or extension ).

Parameters:object (object) – Object.
Returns:Is object read only.
Return type:bool
foundations.trace.setTracerHook(object, hook)[source]

Sets given object tracer hook on given object.

Parameters:
  • hook (object) – Tracer hook.
  • object (object) – Object.
Returns:

Definition success.

Return type:

bool

foundations.trace.getTracerHook(object)[source]

Returns given object tracer hook.

Parameters:object (object) – Object.
Returns:Object tracer hook.
Return type:object
foundations.trace.isTraced(object)[source]

Returns if given object is traced.

Parameters:object (object) – Object.
Returns:Is object traced.
Return type:bool
foundations.trace.isBaseTraced(cls)[source]

Returns if given class has a traced base.

Parameters:cls (object) – Class.
Returns:Is base traced.
Return type:bool
foundations.trace.isUntracable(object)[source]

Returns if given object is untracable.

Parameters:object (object) – Object.
Returns:Is object untracable.
Return type:bool
foundations.trace.setTraced(object)[source]

Sets given object as traced.

Parameters:object (object) – Object.
Returns:Definition success.
Return type:bool
foundations.trace.setUntraced(object)[source]

Sets given object as untraced.

Parameters:object (object) – Object.
Returns:Definition success.
Return type:bool
foundations.trace.setUntracable(object)[source]

Sets given object as untraced.

Parameters:object (object) – Object.
Returns:Definition success.
Return type:bool
foundations.trace.traceWalker(module)[source]

Defines a generator used to walk into modules.

Parameters:module (ModuleType) – Module to walk.
Returns:Class / Function / Method.
Return type:object or object
foundations.trace.getObjectName(object)[source]

Returns given object name.

Parameters:object (object) – Object to retrieve the name.
Returns:Object name.
Return type:unicode
foundations.trace.getTraceName(object)[source]

Returns given object trace name.

Parameters:object (object) – Object.
Returns:Object trace name.
Return type:unicode
foundations.trace.getMethodName(method)[source]

Returns given method name.

Parameters:method (object) – Method to retrieve the name.
Returns:Method name.
Return type:unicode
foundations.trace.isStaticMethod(method)[source]

Returns if given method is a static method.

Parameters:method (object) – Method.
Returns:Is static method.
Return type:bool
foundations.trace.isClassMethod(method)[source]

Returns if given method is a class method.

Parameters:method (object) – Method.
Returns:Is class method.
Return type:bool
foundations.trace.formatArgument(argumentValue)[source]

Returns a string representing an argument / value pair.

Usage:

>>> formatArgument(('x', (0, 1, 2)))
u'x=(0, 1, 2)'
Parameters:argumentValue (tuple) – Argument / value pair.
Returns:Formatted .argument / value pair.
Return type:unicode
foundations.trace.validateTracer(*args)[source]

Validate and finishes a tracer by adding mandatory extra attributes.

Parameters:*args (*) – Arguments.
Returns:Validated wrapped object.
Return type:object
foundations.trace.tracer(object)[source]
Traces execution.
Any method / definition decorated will have it’s execution traced.
Parameters:object (object) – Object to decorate.
Returns:Object.
Return type:object
foundations.trace.untracer(object)[source]

Object is used to untrace given object.

Parameters:object (object) – Object to untrace.
Returns:Untraced object.
Return type:object
foundations.trace.untracable(object)[source]

Marks decorated object as non tracable.

Parameters:object (object) – Object to decorate.
Returns:Object.
Return type:object
foundations.trace.traceFunction(module, function, tracer=<function tracer at 0x102fb66e0>)[source]

Traces given module function using given tracer.

Parameters:
  • module (object) – Module of the function.
  • function (object) – Function to trace.
  • tracer (object) – Tracer.
Returns:

Definition success.

Return type:

bool

foundations.trace.untraceFunction(module, function)[source]

Untraces given module function.

Parameters:
  • module (object) – Module of the function.
  • function (object) – Function to untrace.
Returns:

Definition success.

Return type:

bool

foundations.trace.traceMethod(cls, method, tracer=<function tracer at 0x102fb66e0>)[source]

Traces given class method using given tracer.

Parameters:
  • cls (object) – Class of the method.
  • method (object) – Method to trace.
  • tracer (object) – Tracer.
Returns:

Definition success.

Return type:

bool

foundations.trace.untraceMethod(cls, method)[source]

Untraces given class method.

Parameters:
  • cls (object) – Class of the method.
  • method (object) – Method to untrace.
Returns:

Definition success.

Return type:

bool

foundations.trace.traceProperty(cls, accessor, tracer=<function tracer at 0x102fb66e0>)[source]

Traces given class property using given tracer.

Parameters:
  • cls (object) – Class of the property.
  • accessor (property) – Property to trace.
  • tracer (object) – Tracer.
Returns:

Definition success.

Return type:

bool

foundations.trace.untraceProperty(cls, accessor)[source]

Untraces given class property.

Parameters:
  • cls (object) – Class of the property.
  • accessor (property) – Property to untrace.
Returns:

Definition success.

Return type:

bool

foundations.trace.traceClass(cls, tracer=<function tracer at 0x102fb66e0>, pattern=u'.*', flags=0)[source]

Traces given class using given tracer.

Parameters:
  • cls (object) – Class to trace.
  • tracer (object) – Tracer.
  • pattern (unicode) – Matching pattern.
  • flags (int) – Matching regex flags.
Returns:

Definition success.

Return type:

bool

foundations.trace.untraceClass(cls)[source]

Untraces given class.

Parameters:cls (object) – Class to untrace.
Returns:Definition success.
Return type:bool
foundations.trace.traceModule(module, tracer=<function tracer at 0x102fb66e0>, pattern=u'.*', flags=0)[source]

Traces given module members using given tracer.

Parameters:
  • module (ModuleType) – Module to trace.
  • tracer (object) – Tracer.
  • pattern (unicode) – Matching pattern.
  • flags (int) – Matching regex flags.
Returns:

Definition success.

Return type:

bool

Note:

Only members exported by __all__ attribute will be traced.

foundations.trace.untraceModule(module)[source]

Untraces given module members.

Parameters:module (ModuleType) – Module to untrace.
Returns:Definition success.
Return type:bool
foundations.trace.registerModule(module=None)[source]

Registers given module or caller introspected module in the candidates modules for tracing.

Parameters:module (ModuleType) – Module to register.
Returns:Definition success.
Return type:bool
foundations.trace.installTracer(tracer=<function tracer at 0x102fb66e0>, pattern=u'.*', flags=0)[source]

Installs given tracer in the candidates modules for tracing matching given pattern.

Parameters:
  • tracer (object) – Tracer.
  • pattern (unicode) – Matching pattern.
  • flags (int) – Matching regex flags.
Returns:

Definition success.

Return type:

bool

foundations.trace.uninstallTracer(pattern=u'.*', flags=0)[source]

Installs the tracer in the candidates modules for tracing matching given pattern.

Parameters:
  • pattern (unicode) – Matching pattern.
  • flags (int) – Matching regex flags.
Returns:

Definition success.

Return type:

bool

foundations.trace.evaluateTraceRequest(data, tracer=<function tracer at 0x102fb66e0>)[source]

Evaluate given string trace request.

Usage:

Umbra -t "{'umbra.engine' : ('.*', 0), 'umbra.preferences' : (r'.*', 0)}"
Umbra -t "['umbra.engine', 'umbra.preferences']"
Umbra -t "'umbra.engine, umbra.preferences"
Parameters:
Returns:

Definition success.

Return type:

bool