本文整理汇总了Python中code.InteractiveConsole.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python InteractiveConsole.__init__方法的具体用法?Python InteractiveConsole.__init__怎么用?Python InteractiveConsole.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类code.InteractiveConsole
的用法示例。
在下文中一共展示了InteractiveConsole.__init__方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from code import InteractiveConsole [as 别名]
# 或者: from code.InteractiveConsole import __init__ [as 别名]
def __init__(self, cpu=None, verbose=False):
InteractiveConsole.__init__(self)
self.filename="<stdin>"
self.inQuery = False # True if the shell is in SociaLite query
self.compiler = None
self.declBegin = None
self.declEnd = None
self.locals={}
from impSocialite import setSocialiteVars
setSocialiteVars(self.locals)
self.locals["__name__"] = "__main__"
self.adapter = PythonInterpAdapter(self)
import socialite.functions.PyInterp as PyInterp
PyInterp.set(self.adapter)
示例2: __init__
# 需要导入模块: from code import InteractiveConsole [as 别名]
# 或者: from code.InteractiveConsole import __init__ [as 别名]
def __init__(self, context):
InteractiveConsole.__init__(self, locals={"context": context.getApplicationContext()})
示例3: __init__
# 需要导入模块: from code import InteractiveConsole [as 别名]
# 或者: from code.InteractiveConsole import __init__ [as 别名]
def __init__(self, transform, config):
self.transform = transform
self.config = config
示例4: __init__
# 需要导入模块: from code import InteractiveConsole [as 别名]
# 或者: from code.InteractiveConsole import __init__ [as 别名]
def __init__(self, *args, **kwargs):
self.handler = ExceptionHandler(*args, **kwargs)
kwargs.pop("engine")
kwargs.pop("prompt")
kwargs.pop("arguments")
InteractiveConsole.__init__(self, *args, **kwargs)
示例5: __init__
# 需要导入模块: from code import InteractiveConsole [as 别名]
# 或者: from code.InteractiveConsole import __init__ [as 别名]
def __init__(self, writemethod):
self._write = writemethod
示例6: __init__
# 需要导入模块: from code import InteractiveConsole [as 别名]
# 或者: from code.InteractiveConsole import __init__ [as 别名]
def __init__(self, socket, locals=None):
self.socket = socket
self.handle = socket.makefile('rw')
InteractiveConsole.__init__(self, locals=locals)
self.handle.write(doc)
示例7: run_files
# 需要导入模块: from code import InteractiveConsole [as 别名]
# 或者: from code.InteractiveConsole import __init__ [as 别名]
def run_files(args, verbose=0, inspect=False):
sys.argv = args
filename = args[0]
args = args[1:]
import java.io.File as File
abspath = File(filename).getAbsolutePath()
path = str(abspath[0:abspath.rindex(File.separator)])
sys.path.insert(0, path)
program=open(filename).read()
from pysoc import compiler
src = compiler.compile(program)
from impSocialite import addMod, loadMod, setSocialiteVars
sys.modules.pop("__main__", None)
class FakeConsole:
def __init__(self):
self.locals = None
console = FakeConsole()
adapter = PythonInterpAdapter(console)
import socialite.functions.PyInterp as PyInterp
PyInterp.set(adapter)
mod = addMod("__main__")
setSocialiteVars(mod.__dict__)
console.locals = mod.__dict__
try:
import java.lang.System as Sys
mod = loadMod("__main__", src, filename)
#exec src in locals
except SystemExit:
sys.exit(0)
except:
# adapted from code.py::InteractiveInterpreter::showtraceback
import traceback
try:
tp, value, tb = sys.exc_info()
sys.last_type = tp
sys.last_value = value
sys.last_traceback = tb
tblist = traceback.extract_tb(tb)
del tblist[:1]
list = traceback.format_list(tblist)
if list:
list.insert(0, "Traceback (most recent call last):\n")
list[len(list):] = traceback.format_exception_only(tp, value)
finally:
tblist = tb = None
map(sys.stderr.write, list)
sys.exit(1)
if inspect:
console = SociaLiteConsole(verbose=verbose)
console.initLocals(mod.__dict__)
console.interact("")