pymel.util.utilitytypes.ModuleInterceptor

digraph inheritance43cbfba9b5 { rankdir=TB; ranksep=0.15; nodesep=0.15; size="8.0, 12.0"; "ModuleInterceptor" [fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",URL="#pymel.util.utilitytypes.ModuleInterceptor",style="setlinewidth(0.5)",tooltip="This class is used to intercept an unset attribute of a module to perfrom a callback. The",height=0.25,shape=box,fontsize=8]; }

class ModuleInterceptor(moduleName, callback)

This class is used to intercept an unset attribute of a module to perfrom a callback. The callback will only be performed if the attribute does not exist on the module. Any error raised in the callback will cause the original AttributeError to be raised.

def cb( module, attr):
if attr == ‘this’:
print “intercepted”
else:
raise ValueError

import sys sys.modules[__name__] = ModuleInterceptor(__name__, cb) intercepted

The class does not work when imported into the main namespace.