@@ -356,7 +356,7 @@ init -980 python in mas_submod_utils:
356356 PRIORITY_SORT_KEY = lambda x : x[1 ][2 ]
357357
358358 # START: Decorator Function
359- def functionplugin (_label , _args = () , auto_error_handling = True , priority = 0 ):
359+ def functionplugin (_label , _args = None , auto_error_handling = True , priority = 0 ):
360360 """
361361 Decorator function to register a plugin
362362
@@ -397,14 +397,14 @@ init -980 python in mas_submod_utils:
397397 for _action, data_tuple in sorted_plugins:
398398 if data_tuple[1 ]:
399399 try :
400- store.__run(_action, getArgs (key , _action))
400+ store.__run(_action, __getArgs (key , _action))
401401 except Exception as ex:
402402 store.mas_utils.mas_log.error(" function {0} failed because {1} " .format(_action.__name__ , ex))
403403
404404 else :
405- store.__run(_action, getArgs (key , _action))
405+ store.__run(_action, __getArgs (key , _action))
406406
407- def registerFunction (key , _function , args = () , auto_error_handling = True , priority = DEF_PRIORITY):
407+ def registerFunction (key , _function , args = None , auto_error_handling = True , priority = DEF_PRIORITY):
408408 """
409409 Registers a function to the function_plugins dict
410410
@@ -440,7 +440,10 @@ init -980 python in mas_submod_utils:
440440 return False
441441
442442 # TODO: remove args entirely in r8
443- if args:
443+ if args is None :
444+ args = ()
445+
446+ else :
444447 mas_utils.report_deprecation(
445448 " parameter 'args' in 'registerFunction'" ,
446449 use_instead = " functools.partial" ,
@@ -465,8 +468,9 @@ init -980 python in mas_submod_utils:
465468 function_plugins[key ][_function] = (args, auto_error_handling, priority)
466469 return True
467470
468- def getArgs (key , _function ):
471+ def __getArgs (key , _function ):
469472 """
473+ TODO: remove this with r8
470474 Gets args for the given function at the given key
471475
472476 IN:
@@ -490,14 +494,31 @@ init -980 python in mas_submod_utils:
490494 use_instead = " functools.partial" ,
491495 use_instead_msg_fmt = " Wrap your callable in '{use_instead} ' to provide it args/kwargs."
492496 )
493- def setArgs (key , _function , args = ()):
497+ def getArgs (key , _function ):
498+ """
499+ Gets args for the given function at the given key
500+
501+ IN:
502+ key - key to retrieve the function from
503+ _function - function to retrieve args from
504+
505+ OUT:
506+ list of args if the function is present
507+ If function is not present, None is returned
508+ """
509+ return __getArgs(key , _function)
510+
511+ @ mas_utils.deprecated (
512+ use_instead = " functools.partial" ,
513+ use_instead_msg_fmt = " Wrap your callable in '{use_instead} ' to provide it args/kwargs."
514+ )
515+ def setArgs (key , _function , args = None ):
494516 """
495517 Sets args for the given function at the key
496518
497519 IN:
498520 key - key that the function's function dict is stored in
499521 _function - function to set the args
500- args - list of args (must be in order) to pass to the function (Default: [] )
501522
502523 OUT:
503524 boolean:
@@ -513,9 +534,12 @@ init -980 python in mas_submod_utils:
513534 return False
514535
515536 # Function not in dict
516- elif _function not in func_dict:
537+ if _function not in func_dict:
517538 return False
518539
540+ if args is None :
541+ args = ()
542+
519543 # Too many args provided
520544 elif len (args) > len (inspect.getargspec(_function).args):
521545 store.mas_utils.mas_log.error(" Too many args provided for function {0} " .format(_function.__name__ ))
0 commit comments