+def call_hook_function(fname, arglist):
+ """Safely execute named function with supplied arguments, return result."""
+
+ # all functions relative to mudpy package
+ function = mudpy
+
+ for component in fname.split("."):
+ try:
+ function = getattr(function, component)
+ except AttributeError:
+ log('Could not find mudpy.%s() for arguments "%s"'
+ % (fname, arglist), 7)
+ function = None
+ break
+ if function:
+ try:
+ return function(*arglist)
+ except Exception:
+ log('Calling mudpy.%s(%s) raised an exception...\n%s'
+ % (fname, (*arglist,), traceback.format_exc()), 7)
+
+