def _discover_space(name, globals):
    try:
        return _local.space_stack[-1]
    except (__HOLE__, IndexError):
        pass

    if '__pluginbase_state__' in globals:
        return globals['__pluginbase_state__'].source

    mod_name = globals.get('__name__')
    if mod_name is not None and \
       mod_name.startswith(_internalspace.__name__ + '.'):
        end = mod_name.find('.', len(_internalspace.__name__) + 1)
        space = sys.modules.get(mod_name[:end])
        if space is not None:
            return space.__pluginbase_state__.source
dataset/ETHPy150Open dragondjf/PFramer/util/pluginbase.py/_discover_space