本文整理汇总了Python中lupa.LuaRuntime方法的典型用法代码示例。如果您正苦于以下问题:Python lupa.LuaRuntime方法的具体用法?Python lupa.LuaRuntime怎么用?Python lupa.LuaRuntime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lupa
的用法示例。
在下文中一共展示了lupa.LuaRuntime方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_protocol
# 需要导入模块: import lupa [as 别名]
# 或者: from lupa import LuaRuntime [as 别名]
def load_protocol(self, path):
lua = lupa.LuaRuntime(attribute_handlers=(getter, setter))
self.lua = lua
lua.globals()["flow"] = flow
lua.globals()["channels"] = self.context.get_channels()
lua.globals()["context"] = self.context
source = open(path).read()
try:
lua.execute(source)
self.guiBlocks = lua.eval('setup()')
#lua.eval('gui()')
except Exception as e:
print ('Lua Exception occured: ', e, type(e))
raise
for block in self.guiBlocks:
dock = Dock(block.name)
dock.addWidget(block.widget())
self.dockarea.addDock(dock)
if 'doc_config' in lua.globals():
self.restore_layout()
示例2: __init__
# 需要导入模块: import lupa [as 别名]
# 或者: from lupa import LuaRuntime [as 别名]
def __init__(self):
self._rt = lupa.LuaRuntime(unpack_returned_tuples=True, encoding=None)
if self.eval("type(jit) == 'table'"):
raise RuntimeError("lupa must be linked against Lua, not LuaJIT.\n"
"Please install lupa with `--no-luajit`.")
self._setup_runtime()
示例3: __init__
# 需要导入模块: import lupa [as 别名]
# 或者: from lupa import LuaRuntime [as 别名]
def __init__(self, server, chatbot):
# Init interpreter, create functions/namespaces in Lua's global state
self.lua = LuaRuntime(unpack_returned_tuples=True)
self.lua.execute(load_script("lua_bridge/init.lua"))
# Params: str:namespace, str:name, pyfunc:func
self.new_bind = self.lua.eval("bridge.new_bind")
# Params: str:namespace
self.new_namespace = self.lua.eval("bridge.new_namespace")
self.lua.eval("log.info(\"Initialisation complete\")")
self.server = server
self.chatbot = chatbot
self.create_binds()
示例4: get_label_for_problem
# 需要导入模块: import lupa [as 别名]
# 或者: from lupa import LuaRuntime [as 别名]
def get_label_for_problem(self):
if not self.problem_label_script:
return self.format.get_label_for_problem
def DENY_ALL(obj, attr_name, is_setting):
raise AttributeError()
lua = LuaRuntime(attribute_filter=DENY_ALL, register_eval=False, register_builtins=False)
return lua.eval(self.problem_label_script)
示例5: __init__
# 需要导入模块: import lupa [as 别名]
# 或者: from lupa import LuaRuntime [as 别名]
def __init__(self, username, accountname, apikey):
self.username = username
self.accountName = accountname
self.apiKey = apikey
self.lua = LuaRuntime()
self.urlParser = re.compile('/([a-zA-Z0-9_-]+)/(\d+)')
self.waList = {}
self.waIgnored = {}
self.uidCache = {}
self.idCache = {}
self.dataCache = {'slugs': [], 'uids': [], 'ids': []}
if self.username == 'DISABLED':
self.username = ''
if not os.path.isfile(Path(f'WTF/Account/{self.accountName}/SavedVariables/WeakAuras.lua')):
raise RuntimeError('Incorrect WoW account name!')