Esempio n. 1
0
    def get_signatures_for_frame(self, expression, thread, cur_frame, frame_kind):
        if sys.platform == 'cli':
            code = python_context.CreateSnippet(expression, None, SourceCodeKind.AutoDetect)
            val = code.Execute(Scope(cur_frame.f_globals))
        else:
            val = eval(expression, cur_frame.f_globals, _thread.get_locals(cur_frame, frame_kind))

        return self.collect_signatures(val)
    def get_members_for_frame(self, expression, thread, cur_frame, frame_kind):
        """returns a tuple of the type name, instance members, and type members"""
        getattr_func = getattr
        if not expression:
            all_members = {}
            if sys.platform == 'cli':
                code = python_context.CreateSnippet('vars()', None,
                                                    SourceCodeKind.AutoDetect)
                globals = code.Execute(Scope(cur_frame.f_globals))
                locals = code.Execute(
                    Scope(thread.get_locals(cur_frame, frame_kind)))
            else:
                globals = cur_frame.f_globals
                locals = thread.get_locals(cur_frame, frame_kind)

            for key, value in globals.items():
                all_members[key] = self.get_type_name(value)

            for key, value in locals.items():
                all_members[key] = self.get_type_name(value)

            return '', all_members, {}
        else:
            if sys.platform == 'cli':
                scope = Scope(cur_frame.f_globals)

                code = python_context.CreateSnippet(expression, None,
                                                    SourceCodeKind.AutoDetect)
                val = code.Execute(scope)

                code = python_context.CreateSnippet('dir(' + expression + ')',
                                                    None,
                                                    SourceCodeKind.AutoDetect)
                members = code.Execute(scope)

                code = python_context.CreateSnippet(
                    'lambda value, name: getattr(value, name)', None,
                    SourceCodeKind.AutoDetect)
                getattr_func = code.Execute(scope)
            else:
                val = eval(expression, cur_frame.f_globals,
                           thread.get_locals(cur_frame, frame_kind))
                members = dir(val)

        return self.collect_members(val, members, getattr_func)
Esempio n. 3
0
    def __init__(self, mod_name='__main__'):
        import threading
        ReplBackend.__init__(self)
        if mod_name is not None:
            if sys.platform == 'cli':
                self.exec_mod = Scope()
                self.exec_mod.__name__ = '__main__'
            else:
                sys.modules[mod_name] = self.exec_mod = imp.new_module(mod_name)
        else:
            self.exec_mod = sys.modules['__main__']

        self.code_flags = 0
        self.execute_item = None
        self.execute_item_lock = threading.Lock()
        self.execute_item_lock.acquire()    # lock starts acquired (we use it like manual reset event)
Esempio n. 4
0
    def __init__(self, mod_name='__main__'):
        import threading
        ReplBackend.__init__(self)
        if mod_name is not None:
            if sys.platform == 'cli':
                self.exec_mod = Scope()
                self.exec_mod.__name__ = '__main__'
            else:
                self.exec_mod = imp.new_module(mod_name)
                # On 2.6, the below messes up the globals of the calling script
                # if it is in sys.modules of the same name.
                if sys.version_info >= (2, 7):
                    sys.modules[mod_name] = self.exec_mod
        else:
            self.exec_mod = sys.modules['__main__']

        self.code_flags = 0
        self.execute_item = None
        self.execute_item_lock = threading.Lock()
        self.execute_item_lock.acquire()    # lock starts acquired (we use it like manual reset event)