當前位置: 首頁>>代碼示例>>Python>>正文


Python lupa.LuaRuntime方法代碼示例

本文整理匯總了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() 
開發者ID:strfry,項目名稱:OpenNFB,代碼行數:25,代碼來源:launcher.py

示例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() 
開發者ID:jbaiter,項目名稱:chdkptp.py,代碼行數:8,代碼來源:lua.py

示例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() 
開發者ID:th3-z,項目名稱:kf2-magicked-admin,代碼行數:17,代碼來源:lua_bridge.py

示例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) 
開發者ID:DMOJ,項目名稱:online-judge,代碼行數:10,代碼來源:contest.py

示例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!') 
開發者ID:AcidWeb,項目名稱:CurseBreaker,代碼行數:17,代碼來源:Wago.py


注:本文中的lupa.LuaRuntime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。