##// END OF EJS Templates
Use globals dict to find right export function instead of...
Jonathan Frederic -
Show More
@@ -474,14 +474,10 b' def export_by_name(nb, template_name, config=None, transformers=None, filters=No'
474 specifies what extension the output should be saved as.
474 specifies what extension the output should be saved as.
475 """
475 """
476
476
477 #Use reflection to get functions defined in this module.
477 function_name = "export_" + template_name.lower()
478 cls_functions = inspect.getmembers(sys.modules[__name__], inspect.isfunction)
479
478
480 #Check if the characters following "export_" (7 char) equals the template name.
479 if function_name in globals():
481 for (function_name, function_handle) in cls_functions:
480 return globals()[function_name](nb, config, transformers, filters)
482 function_name = function_name.lower()
481 else:
483 if (len(function_name) > 7 and function_name[7:] == template_name.lower()):
482 return None
484 return function_handle(nb, config, transformers, filters)
485
486 return None
487 No newline at end of file
483
General Comments 0
You need to be logged in to leave comments. Login now