本文整理匯總了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!')