Correct use of callable in prototype creation
This commit is contained in:
parent
484e5e6b1c
commit
a9fd49474d
1 changed files with 6 additions and 9 deletions
|
|
@ -293,6 +293,7 @@ def search_prototype(key=None, tags=None):
|
||||||
if tagset.intersection(prototype.get("prototype_tags", []))}
|
if tagset.intersection(prototype.get("prototype_tags", []))}
|
||||||
else:
|
else:
|
||||||
mod_matches = _MODULE_PROTOTYPES
|
mod_matches = _MODULE_PROTOTYPES
|
||||||
|
|
||||||
if key:
|
if key:
|
||||||
if key in mod_matches:
|
if key in mod_matches:
|
||||||
# exact match
|
# exact match
|
||||||
|
|
@ -565,11 +566,7 @@ def protfunc_parser(value, available_functions=None, testing=False, stacktrace=F
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if not isinstance(value, basestring):
|
if not isinstance(value, basestring):
|
||||||
try:
|
return value
|
||||||
value = value.dbref
|
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
value = to_str(value, force_string=True)
|
|
||||||
|
|
||||||
available_functions = PROT_FUNCS if available_functions is None else available_functions
|
available_functions = PROT_FUNCS if available_functions is None else available_functions
|
||||||
|
|
||||||
|
|
@ -728,16 +725,16 @@ def init_spawn_value(value, validator=None):
|
||||||
any (any): The (potentially pre-processed value to use for this prototype key)
|
any (any): The (potentially pre-processed value to use for this prototype key)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
value = protfunc_parser(value)
|
|
||||||
validator = validator if validator else lambda o: o
|
validator = validator if validator else lambda o: o
|
||||||
if callable(value):
|
if callable(value):
|
||||||
return validator(value())
|
value = validator(value())
|
||||||
elif value and is_iter(value) and callable(value[0]):
|
elif value and is_iter(value) and callable(value[0]):
|
||||||
# a structure (callable, (args, ))
|
# a structure (callable, (args, ))
|
||||||
args = value[1:]
|
args = value[1:]
|
||||||
return validator(value[0](*make_iter(args)))
|
value = validator(value[0](*make_iter(args)))
|
||||||
else:
|
else:
|
||||||
return validator(value)
|
value = validator(value)
|
||||||
|
return protfunc_parser(value)
|
||||||
|
|
||||||
|
|
||||||
def value_to_obj_or_any(value):
|
def value_to_obj_or_any(value):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue