bugfix
This commit is contained in:
parent
6fd89a00ae
commit
2f10073b3b
@ -1,6 +1,7 @@
|
||||
# -*- coding:utf8 -*-
|
||||
import re
|
||||
from appPublic.dictObject import DictObject
|
||||
from appPublic.registerfunction import rfrun
|
||||
class ConvertException(Exception):
|
||||
pass
|
||||
|
||||
@ -13,7 +14,8 @@ class ArgsConvert(object):
|
||||
sl2 = [ u'\\' + c for c in self.subfixString ]
|
||||
ps = u''.join(sl1)
|
||||
ss = u''.join(sl2)
|
||||
re1 = ps + r"[_a-zA-Z_\u4e00-\u9fa5][a-zA-Z_0-9\u4e00-\u9fa5\,\.\'\{\}\[\]\(\)\-\+\*\/]*" + ss
|
||||
# re1 = ps + r"[_a-zA-Z_\u4e00-\u9fa5][a-zA-Z_0-9\u4e00-\u9fa5\,\.\'\{\}\[\]\(\)\-\+\*\/]*" + ss
|
||||
re1 = ps + r".*?" + ss
|
||||
self.re1 = re1
|
||||
# print( self.re1,len(self.re1),len(re1),type(self.re1))
|
||||
|
||||
@ -43,11 +45,13 @@ class ArgsConvert(object):
|
||||
return vs[len(self.preString):-len(self.subfixString)]
|
||||
|
||||
def getVarValue(self,var,namespace,default):
|
||||
ns = DictObject(**namespace.copy())
|
||||
ns.rfrun = rfrun
|
||||
v = default
|
||||
try:
|
||||
v = eval(var,namespace)
|
||||
v = eval(var,ns)
|
||||
except Exception as e:
|
||||
v = namespace.get(var, None)
|
||||
v = ns.get(var, None)
|
||||
if v:
|
||||
return v
|
||||
if callable(default):
|
||||
|
@ -19,6 +19,15 @@ class RegisterFunction:
|
||||
def get(self,name):
|
||||
return self.registKW.get(name,None)
|
||||
|
||||
def run(self, name, *args, **kw):
|
||||
f = self.get(name)
|
||||
if iscoroutinefunction(f):
|
||||
print(f'{name} is a coro')
|
||||
return None
|
||||
if f:
|
||||
return f(*args, **kw)
|
||||
error(f'{name} not register')
|
||||
|
||||
async def exe(self, name, *args, **kw):
|
||||
f = self.get(name)
|
||||
if f is None:
|
||||
@ -64,9 +73,13 @@ def registerFunction(name, func):
|
||||
rf = RegisterFunction()
|
||||
rf.register(name, func)
|
||||
|
||||
async def rfexe(rfname, *args):
|
||||
async def rfexe(rfname, *args, **kw):
|
||||
rf = RegisterFunction()
|
||||
return await rf.exe(rfname, *args)
|
||||
return await rf.exe(rfname, *args, **kw)
|
||||
|
||||
def rfrun(rfname, *args, **kw):
|
||||
rf = RegisterFunction()
|
||||
return rf.run(rfname, *args, **kw)
|
||||
|
||||
async def main():
|
||||
d = {}
|
||||
|
Loading…
Reference in New Issue
Block a user