Replace inlinefunc parser with FuncParser mostly
This commit is contained in:
parent
8c3910a033
commit
773bb31f55
10 changed files with 294 additions and 322 deletions
|
|
@ -151,6 +151,7 @@ def add(*args, **kwargs):
|
|||
val1, val2 = args[0], args[1]
|
||||
# try to convert to python structures, otherwise, keep as strings
|
||||
try:
|
||||
print("val1", val1, type(literal_eval(val1)))
|
||||
val1 = literal_eval(val1.strip())
|
||||
except Exception:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ from evennia.utils.utils import (
|
|||
)
|
||||
from evennia.locks.lockhandler import validate_lockstring, check_lockstring
|
||||
from evennia.utils import logger
|
||||
from evennia.utils.funcparser import FuncParser
|
||||
from evennia.utils import inlinefuncs, dbserialize
|
||||
from evennia.utils.evtable import EvTable
|
||||
|
||||
|
|
@ -758,9 +759,11 @@ def protfunc_parser(value, available_functions=None, testing=False, stacktrace=F
|
|||
|
||||
available_functions = PROT_FUNCS if available_functions is None else available_functions
|
||||
|
||||
result = inlinefuncs.parse_inlinefunc(
|
||||
value, available_funcs=available_functions, stacktrace=stacktrace, testing=testing, **kwargs
|
||||
)
|
||||
result = FuncParser(available_functions).parse(value, raise_errors=True, **kwargs)
|
||||
|
||||
# result = inlinefuncs.parse_inlinefunc(
|
||||
# value, available_funcs=available_functions, stacktrace=stacktrace, testing=testing, **kwargs
|
||||
# )
|
||||
|
||||
err = None
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ class TestProtFuncs(EvenniaTest):
|
|||
self.assertEqual(protlib.protfunc_parser("$add(1, 2)"), 3)
|
||||
self.assertEqual(protlib.protfunc_parser("$add(10, 25)"), 35)
|
||||
self.assertEqual(
|
||||
protlib.protfunc_parser("$add('''[1,2,3]''', '''[4,5,6]''')"), [1, 2, 3, 4, 5, 6]
|
||||
protlib.protfunc_parser("$add('[1,2,3]', '[4,5,6]')"), [1, 2, 3, 4, 5, 6]
|
||||
)
|
||||
self.assertEqual(protlib.protfunc_parser("$add(foo, bar)"), "foo bar")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue