

def toolkit_object(name):
    ' Return the toolkit specific object with the given name.\n\n    Parameters\n    ----------\n    name : str\n        The name consists of the relative module path and the object name\n        separated by a colon.\n    '
    (mname, oname) = name.split(':')
    be_mname = (_toolkit_backend + mname)

    class Unimplemented(object):
        " An unimplemented toolkit object\n\n        This is returned if an object isn't implemented by the selected\n        toolkit.  It raises an exception if it is ever instantiated.\n        "

        def __init__(self, *args, **kwargs):
            raise NotImplementedError(("the %s pyface backend doesn't implement %s" % (ETSConfig.toolkit, oname)))
    be_obj = Unimplemented
    try:
        __import__(be_mname)
        try:
            be_obj = getattr(sys.modules[be_mname], oname)
        except AttributeError:
            pass
    except ImportError as exc:
        if all(((part not in exc.args[0]) for part in mname.split('.'))):
            raise
        if ('ETS_DEBUG' in os.environ):
            import traceback
            frames = traceback.extract_tb(sys.exc_traceback)
            (filename, lineno, function, text) = frames[(- 1)]
            if (not (_toolkit_backend in filename)):
                raise
    return be_obj

dataset/ETHPy150Open enthought/pyface/pyface/toolkit.py toolkit_object/original