Tf module#

Summary: The Tf (Tools Foundations) module.


Tf – Tools Foundation

Exceptions:

Classes:

CallContext

CatchAndRepostErrors()

This context manager & decorator can be used to catch Tf.ErrorException and repost its held errors to the thread's Tf.Error list without raising a Python exception, halting unwinding.

Debug

DiagnosticType

Enum

Error

MallocTag

NamedTemporaryFile([suffix, prefix, dir, text])

A named temporary file which keeps the internal file handle closed.

Notice

PyModuleWasLoaded

RefPtrTracker

ScopeDescription

This class lets us expose TfScopeDescription to python for use as a "context manager" object, for use with the 'with'-statement.

ScriptModuleLoader

Singleton

StatusObject

Stopwatch

Tf_PyEnumWrapper

Tf_TestAnnotatedBoolResult

Tf_TestPyContainerConversions

Tf_TestPyOptionalStd

Type

Warning

WindowsImportWrapper()

Functions:

Fatal(msg)

Raise a fatal error to the Tf Diagnostic system.

GetCodeLocation(framesUp)

Returns a tuple (moduleName, functionName, fileName, lineNo).

PrepareModule(module, result)

PrepareModule(module, result) -- Prepare an extension module at import time.

PreparePythonModule([moduleName])

Prepare an extension module at import time.

RaiseCodingError(msg)

Raise a coding error to the Tf Diagnostic system.

RaiseRuntimeError(msg)

Raise a runtime error to the Tf Diagnostic system.

Status(msg[, verbose])

Issues a status update to the Tf diagnostic system.

Warn(msg[, template])

Issue a warning via the TfDiagnostic system.

exception pxr.Tf.CppException#
exception pxr.Tf.ErrorException(*args)#
class pxr.Tf.CallContext#

Attributes:

property file#
property function#
property line#
property prettyFunction#
class pxr.Tf.CatchAndRepostErrors#

This context manager & decorator can be used to catch Tf.ErrorException and repost its held errors to the thread’s Tf.Error list without raising a Python exception, halting unwinding. For example, the following will raise a Tf.ErrorException containing the “test” Coding Error. This will be caught by the CatchAndRepostErrors object, and the “test” Error will be re-posted to the thread’s error list. Then exception propagation will cease and ordinary control flow will continue.

with Tf.CatchAndRepostErrors():

Tf.RaiseCodingError(‘test’)

This can be useful to sidestep SIP’s virtual function bindings from blocking exceptions, retaining Tf.Errors so they can propagate to callers. Here, the paintGL() virtual override can capture any Tf.ErrorExceptions raised during its execution, and by reposting the errors to the Tf.Error list, callers can observe them later.

@Tf.CatchAndRepostErrors(): def paintGL(self):

self._renderer.Render()

class pxr.Tf.Debug#

Methods:

static GetDebugSymbolDescription()#
static GetDebugSymbolDescriptions()#
static GetDebugSymbolNames()#
static IsDebugSymbolNameEnabled()#
static SetDebugSymbolsByName()#
static SetOutputFile()#
class pxr.Tf.DiagnosticType#

Methods:

Attributes:

static GetValueFromName()#
allValues = (Tf.TF_DIAGNOSTIC_CODING_ERROR_TYPE, Tf.TF_DIAGNOSTIC_FATAL_CODING_ERROR_TYPE, Tf.TF_DIAGNOSTIC_RUNTIME_ERROR_TYPE, Tf.TF_DIAGNOSTIC_FATAL_ERROR_TYPE, Tf.TF_DIAGNOSTIC_NONFATAL_ERROR_TYPE, Tf.TF_DIAGNOSTIC_WARNING_TYPE, Tf.TF_DIAGNOSTIC_STATUS_TYPE, Tf.TF_APPLICATION_EXIT_TYPE)#
class pxr.Tf.Enum#

Methods:

static GetValueFromFullName()#
class pxr.Tf.Error#

Classes:

Attributes:

errorCode

The error code posted for this error.

errorCodeString

The error code posted for this error, as a string.

class Mark#

Methods:

Clear

GetErrors

A list of the errors held by this mark.

IsClean

RaiseIfNotClean

If this mark is not clean, raise a Tf.ErrorException with the contained errors, otherwise do nothing.

SetMark

Clear()#
GetErrors()#

A list of the errors held by this mark.

IsClean()#
RaiseIfNotClean()#

If this mark is not clean, raise a Tf.ErrorException with the contained errors, otherwise do nothing.

SetMark()#
property errorCode#

The error code posted for this error.

property errorCodeString#

The error code posted for this error, as a string.

class pxr.Tf.MallocTag#

Classes:

Methods:

class CallTree#

Classes:

Methods:

class CallSite#

Attributes:

property nBytes#
property name#
class PathNode#

Methods:

Attributes:

GetChildren()#
property nAllocations#
property nBytes#
property nBytesDirect#
property siteName#
GetCallSites()#
GetPrettyPrintString()#
GetRoot()#
LoadReport()#
LogReport()#
Report()#
static GetCallStacks()#
static GetCallTree()#
static GetMaxTotalBytes()#
static GetTotalBytes()#
static Initialize()#
static IsInitialized()#
static SetCapturedMallocStacksMatchList()#
static SetDebugMatchList()#
class pxr.Tf.NamedTemporaryFile(suffix='', prefix='', dir=None, text=False)#

A named temporary file which keeps the internal file handle closed. A class which constructs a temporary file(that isn’t open) on __enter__, provides its name as an attribute, and deletes it on __exit__.

Note: The constructor args for this object match those of python’s tempfile.mkstemp() function, and will have the same effect on the underlying file created.

Attributes:

name

The path for the temporary file created.

property name#

The path for the temporary file created.

class pxr.Tf.Notice#

Classes:

Listener

Represents the Notice connection between senders and receivers of notices.

Methods:

Register(noticeType, callback, sender)

noticeType : Tf.Notice callback : function sender : object

RegisterGlobally(noticeType, callback)

noticeType : Tf.Notice callback : function

Send

Send(sender)

SendGlobally

SendGlobally()

class Listener#

Represents the Notice connection between senders and receivers of notices. When a Listener object expires the connection is broken. You can also use the Revoke() function to break the connection. A Listener object is returned from the Register() and RegisterGlobally() functions.

Methods:

Revoke

Revoke()

Revoke()#

Revoke()

Revoke interest by a notice listener. This function revokes interest in the particular notice type and call-back method that its Listener object was registered for.

static Register(noticeType, callback, sender) Listener#

noticeType : Tf.Notice callback : function sender : object

Register a listener as being interested in a TfNotice type from a specific sender. Notice listener will get sender as an argument. Registration of interest in a notice class N automatically registers interest in all classes derived from N. When a notice of appropriate type is received, the listening object’s member-function method is called with the notice. To reverse the registration, call Revoke() on the Listener object returned by this call.

Register( noticeType, callback, sender ) -> Listener

noticeType : Tf.Notice callback : function sender : object

Register a listener as being interested in a TfNotice type from a specific sender. Notice listener will get sender as an argument. Registration of interest in a notice class N automatically registers interest in all classes derived from N. When a notice of appropriate type is received, the listening object’s member-function method is called with the notice. To reverse the registration, call Revoke() on the Listener object returned by this call.

static RegisterGlobally(noticeType, callback) Listener#

noticeType : Tf.Notice callback : function

Register a listener as being interested in a TfNotice type from any sender. The notice listener does not get sender as an argument.

Send()#

Send(sender)

sender : object

Deliver the notice to interested listeners, returning the number of interested listeners. This is the recommended form of Send. It takes the sender as an argument. Listeners that registered for the given sender AND listeners that registered globally will get the notice.

Send(sender)

sender : object

Deliver the notice to interested listeners, returning the number of interested listeners. This is the recommended form of Send. It takes the sender as an argument. Listeners that registered for the given sender AND listeners that registered globally will get the notice.

SendGlobally()#

SendGlobally()

Deliver the notice to interested listeners. For most clients it is recommended to use the Send(sender) version of Send() rather than this one. Clients that use this form of Send will prevent listeners from being able to register to receive notices based on the sender of the notice. ONLY listeners that registered globally will get the notice.

class pxr.Tf.PyModuleWasLoaded#

Methods:

name()#
class pxr.Tf.RefPtrTracker#

Methods:

Attributes:

expired

True if this object has expired, False otherwise.

GetAllTracesReport()#
GetAllWatchedCountsReport()#
GetTracesReportForWatched()#
property expired#

True if this object has expired, False otherwise.

class pxr.Tf.ScopeDescription#

This class lets us expose TfScopeDescription to python for use as a “context manager” object, for use with the ‘with’-statement. For example:

with Tf.ScopeDescription(“Solving the halting problem”):

# Code that solves the halting problem.

It can also be used as a decorator for an entire function or method, for convenience:

@Tf.ScopeDescription(“Solving the halting problem”); def SolveHaltingProblem():

# Code that solves the halting problem.

Note that the description passed to the decorator is an expression that is evaluated only once at declaration time. If a dynamic description is needed, use the with-statement pattern instead.

class pxr.Tf.ScriptModuleLoader#

Methods:

Attributes:

expired

True if this object has expired, False otherwise.

GetModulesDict()#
WriteDotFile()#
property expired#

True if this object has expired, False otherwise.

class pxr.Tf.Singleton#
class pxr.Tf.StatusObject#
class pxr.Tf.Stopwatch#

Methods:

Attributes:

AddFrom()#
Reset()#
Start()#
Stop()#
property microseconds#
property milliseconds#
property nanoseconds#
property sampleCount#
property seconds#
class pxr.Tf.Tf_PyEnumWrapper#

Attributes:

property displayName#
property fullName#
property name#
property value#
class pxr.Tf.Tf_TestAnnotatedBoolResult#

Attributes:

property annotation#
class pxr.Tf.Tf_TestPyContainerConversions#

Methods:

static GetPairTimesTwo()#
static GetTokens()#
static GetTupleTimesTwo()#
static GetVectorTimesTwo()#
static Init()#
class pxr.Tf.Tf_TestPyOptionalStd#

Methods:

static TakesOptional()#
static TestOptionalChar()#
static TestOptionalDouble()#
static TestOptionalFloat()#
static TestOptionalInt()#
static TestOptionalLong()#
static TestOptionalShort()#
static TestOptionalString()#
static TestOptionalStringVector()#
static TestOptionalUChar()#
static TestOptionalUInt()#
static TestOptionalULong()#
static TestOptionalUShort()#
class pxr.Tf.Type#

Methods:

Attributes:

AddAlias()#
static Define()#
static Find()#
static FindByName()#
FindDerivedByName()#
GetAliases()#
GetAllAncestorTypes()#
GetAllDerivedTypes()#
static GetRoot()#
IsA()#
Unknown = Tf.Type.Unknown#
property baseTypes#
property derivedTypes#
property isEnumType#
property isPlainOldDataType#
property isUnknown#
property pythonClass#
property sizeof#
property typeName#
class pxr.Tf.Warning#
class pxr.Tf.WindowsImportWrapper#
pxr.Tf.Fatal(msg)#

Raise a fatal error to the Tf Diagnostic system.

pxr.Tf.GetCodeLocation(framesUp)#

Returns a tuple (moduleName, functionName, fileName, lineNo).

To trace the current location of python execution, use GetCodeLocation(). By default, the information is returned at the current stack-frame; thus

info = GetCodeLocation()

will return information about the line that GetCodeLocation() was called from. One can write:

def genericDebugFacility():

info = GetCodeLocation(1) # print out data

def someCode():

… if bad:

genericDebugFacility()

and genericDebugFacility() will get information associated with its caller, i.e. the function someCode().

pxr.Tf.PrepareModule(module, result)#

PrepareModule(module, result) – Prepare an extension module at import time. Generally, this should only be called by the __init__.py script for a module upon loading a boost python module (generally ‘_libName.so’).

pxr.Tf.PreparePythonModule(moduleName=None)#

Prepare an extension module at import time. This will import the Python module associated with the caller’s module (e.g. ‘_tf’ for ‘pxr.Tf’) or the module with the specified moduleName and copy its contents into the caller’s local namespace.

Generally, this should only be called by the __init__.py script for a module upon loading a boost python module (generally ‘_libName.so’).

pxr.Tf.RaiseCodingError(msg)#

Raise a coding error to the Tf Diagnostic system.

pxr.Tf.RaiseRuntimeError(msg)#

Raise a runtime error to the Tf Diagnostic system.

pxr.Tf.Status(msg, verbose=True)#

Issues a status update to the Tf diagnostic system.

If verbose is True (the default) then information about where in the code the status update was issued from is included.

pxr.Tf.Warn(msg, template='')#

Issue a warning via the TfDiagnostic system.

At this time, template is ignored.