python类GetCurrentRuntime()的实例源码

visualstudio_py_repl.py 文件源码 项目:pythonVSCode 作者: DonJayamanne 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def execute_code_work_item(self):
        _debug_write('Executing: ' + repr(self.current_code))
        stripped_code = self.current_code.strip()
        if stripped_code:
            if sys.platform == 'cli':
                code_to_send = ''
                for line in stripped_code.split('\n'):
                    stripped = line.strip()
                    if (stripped.startswith('#') or not stripped) and not code_to_send:
                        continue
                    code_to_send += line + '\n'

                code = python_context.CreateSnippet(code_to_send, None, SourceCodeKind.InteractiveCode)
                dispatcher = clr.GetCurrentRuntime().GetLanguage(PythonContext).GetCommandDispatcher()
                if dispatcher is not None:
                    dispatcher(self.python_executor(code))
                else:
                    code.Execute(self.exec_mod)
            else:
                code = compile(self.current_code, '<stdin>', 'single', self.code_flags)
                self.code_flags |= (code.co_flags & BasicReplBackend.future_bits)
                exec(code, self.exec_mod.__dict__, self.exec_mod.__dict__)
        self.current_code = None
visualstudio_py_repl.py 文件源码 项目:pythonVSCode 作者: DonJayamanne 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def execute_code_work_item(self):
        _debug_write('Executing: ' + repr(self.current_code))
        stripped_code = self.current_code.strip()
        if stripped_code:
            if sys.platform == 'cli':
                code_to_send = ''
                for line in stripped_code.split('\n'):
                    stripped = line.strip()
                    if (stripped.startswith('#') or not stripped) and not code_to_send:
                        continue
                    code_to_send += line + '\n'

                code = python_context.CreateSnippet(code_to_send, None, SourceCodeKind.InteractiveCode)
                dispatcher = clr.GetCurrentRuntime().GetLanguage(PythonContext).GetCommandDispatcher()
                if dispatcher is not None:
                    dispatcher(self.python_executor(code))
                else:
                    code.Execute(self.exec_mod)
            else:
                code = compile(self.current_code, '<stdin>', 'single', self.code_flags)
                self.code_flags |= (code.co_flags & BasicReplBackend.future_bits)
                exec(code, self.exec_mod.__dict__, self.exec_mod.__dict__)
        self.current_code = None
visualstudio_py_repl.py 文件源码 项目:HomeAutomation 作者: gs2671 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def execute_code_work_item(self):
        _debug_write('Executing: ' + repr(self.current_code))
        stripped_code = self.current_code.strip()

        if sys.platform == 'cli':
            code_to_send = ''
            for line in stripped_code.split('\n'):
                stripped = line.strip()
                if (stripped.startswith('#') or not stripped) and not code_to_send:
                    continue
                code_to_send += line + '\n'

            code = python_context.CreateSnippet(code_to_send, None, SourceCodeKind.InteractiveCode)
            dispatcher = clr.GetCurrentRuntime().GetLanguage(PythonContext).GetCommandDispatcher()
            if dispatcher is not None:
                dispatcher(self.python_executor(code))
            else:
                code.Execute(self.exec_mod)
        else:
            code = compile(self.current_code, '<stdin>', 'single', self.code_flags)
            self.code_flags |= (code.co_flags & BasicReplBackend.future_bits)
            exec(code, self.exec_mod.__dict__, self.exec_mod.__dict__)
        self.current_code = None
visualstudio_py_repl.py 文件源码 项目:AutoDiff 作者: icewall 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def execute_code_work_item(self):
        _debug_write('Executing: ' + repr(self.current_code))
        stripped_code = self.current_code.strip()

        if sys.platform == 'cli':
            code_to_send = ''
            for line in stripped_code.split('\n'):
                stripped = line.strip()
                if (stripped.startswith('#') or not stripped) and not code_to_send:
                    continue
                code_to_send += line + '\n'

            code = python_context.CreateSnippet(code_to_send, None, SourceCodeKind.InteractiveCode)
            dispatcher = clr.GetCurrentRuntime().GetLanguage(PythonContext).GetCommandDispatcher()
            if dispatcher is not None:
                dispatcher(self.python_executor(code))
            else:
                code.Execute(self.exec_mod)
        else:
            code = compile(self.current_code, '<stdin>', 'single', self.code_flags)
            self.code_flags |= (code.co_flags & BasicReplBackend.future_bits)
            exec(code, self.exec_mod.__dict__, self.exec_mod.__dict__)
        self.current_code = None
visualstudio_py_repl.py 文件源码 项目:xidian-sfweb 作者: Gear420 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def execute_code_work_item(self):
        _debug_write('Executing: ' + repr(self.current_code))
        stripped_code = self.current_code.strip()

        if sys.platform == 'cli':
            code_to_send = ''
            for line in stripped_code.split('\n'):
                stripped = line.strip()
                if (stripped.startswith('#') or not stripped) and not code_to_send:
                    continue
                code_to_send += line + '\n'

            code = python_context.CreateSnippet(code_to_send, None, SourceCodeKind.InteractiveCode)
            dispatcher = clr.GetCurrentRuntime().GetLanguage(PythonContext).GetCommandDispatcher()
            if dispatcher is not None:
                dispatcher(self.python_executor(code))
            else:
                code.Execute(self.exec_mod)
        else:
            code = compile(self.current_code, '<stdin>', 'single', self.code_flags)
            self.code_flags |= (code.co_flags & BasicReplBackend.future_bits)
            exec(code, self.exec_mod.__dict__, self.exec_mod.__dict__)
        self.current_code = None
visualstudio_py_repl.py 文件源码 项目:skojjt 作者: martin-green 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def execute_code_work_item(self):
        _debug_write('Executing: ' + repr(self.current_code))
        stripped_code = self.current_code.strip()

        if sys.platform == 'cli':
            code_to_send = ''
            for line in stripped_code.split('\n'):
                stripped = line.strip()
                if (stripped.startswith('#') or not stripped) and not code_to_send:
                    continue
                code_to_send += line + '\n'

            code = python_context.CreateSnippet(code_to_send, None, SourceCodeKind.InteractiveCode)
            dispatcher = clr.GetCurrentRuntime().GetLanguage(PythonContext).GetCommandDispatcher()
            if dispatcher is not None:
                dispatcher(self.python_executor(code))
            else:
                code.Execute(self.exec_mod)
        else:
            code = compile(self.current_code, '<stdin>', 'single', self.code_flags)
            self.code_flags |= (code.co_flags & BasicReplBackend.future_bits)
            exec(code, self.exec_mod.__dict__, self.exec_mod.__dict__)
        self.current_code = None
clrtype.py 文件源码 项目:EdgeHTTP2Fuzzer 作者: sirusdv 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_dynamic_operations_field():
        if ClrClass.dynamic_operations_field: 
            return ClrClass.dynamic_operations_field
        python_context = clr.GetCurrentRuntime().GetLanguage(PythonContext)
        dynamic_operations = DynamicOperations(python_context)

        typegen = Snippets.Shared.DefineType(
            "DynamicOperationsHolder" + str(hash(python_context)), 
            object, 
            True, 
            False)
        typebld = typegen.TypeBuilder
        typebld.DefineField(
            "DynamicOperations",
            DynamicOperations,
            FieldAttributes.Public | FieldAttributes.Static)
        new_type = typebld.CreateType()
        ClrClass.dynamic_operations_field = new_type.GetField("DynamicOperations")

        ClrClass.dynamic_operations_field.SetValue(None, dynamic_operations)

        return ClrClass.dynamic_operations_field
visualstudio_py_repl.py 文件源码 项目:DjangoWebProject 作者: wrkettlitz 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def execute_code_work_item(self):
        _debug_write('Executing: ' + repr(self.current_code))
        stripped_code = self.current_code.strip()

        if sys.platform == 'cli':
            code_to_send = ''
            for line in stripped_code.split('\n'):
                stripped = line.strip()
                if (stripped.startswith('#') or not stripped) and not code_to_send:
                    continue
                code_to_send += line + '\n'

            code = python_context.CreateSnippet(code_to_send, None, SourceCodeKind.InteractiveCode)
            dispatcher = clr.GetCurrentRuntime().GetLanguage(PythonContext).GetCommandDispatcher()
            if dispatcher is not None:
                dispatcher(self.python_executor(code))
            else:
                code.Execute(self.exec_mod)
        else:
            code = compile(self.current_code, '<stdin>', 'single', self.code_flags)
            self.code_flags |= (code.co_flags & BasicReplBackend.future_bits)
            exec(code, self.exec_mod.__dict__, self.exec_mod.__dict__)
        self.current_code = None
visualstudio_py_repl.py 文件源码 项目:ApiRestPythonTest 作者: rvfvazquez 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def execute_code_work_item(self):
        _debug_write('Executing: ' + repr(self.current_code))
        stripped_code = self.current_code.strip()

        if sys.platform == 'cli':
            code_to_send = ''
            for line in stripped_code.split('\n'):
                stripped = line.strip()
                if (stripped.startswith('#') or not stripped) and not code_to_send:
                    continue
                code_to_send += line + '\n'

            code = python_context.CreateSnippet(code_to_send, None, SourceCodeKind.InteractiveCode)
            dispatcher = clr.GetCurrentRuntime().GetLanguage(PythonContext).GetCommandDispatcher()
            if dispatcher is not None:
                dispatcher(self.python_executor(code))
            else:
                code.Execute(self.exec_mod)
        else:
            code = compile(self.current_code, '<stdin>', 'single', self.code_flags)
            self.code_flags |= (code.co_flags & BasicReplBackend.future_bits)
            exec(code, self.exec_mod.__dict__, self.exec_mod.__dict__)
        self.current_code = None


问题


面经


文章

微信
公众号

扫码关注公众号