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
python类GetCurrentRuntime()的实例源码
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
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
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
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
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
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
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
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