Add None check to fill_template...

... as requested by @nsoranzo.
This commit is contained in:
John Chilton
2016-08-16 14:12:17 -04:00
parent 0110d5a05a
commit e06cf9a978
+9
View File
@@ -1,7 +1,16 @@
"""Entry point for the usage of Cheetah templating within Galaxy."""
from Cheetah.Template import Template
def fill_template( template_text, context=None, **kwargs ):
"""Fill a cheetah template out for specified context.
If template_text is None, an exception will be thrown, if context
is None (the default) - keyword arguments to this function will be used
as the context.
"""
if template_text is None:
raise TypeError("Template text specified as None to fill_template.")
if not context:
context = kwargs
return str( Template( source=template_text, searchList=[context] ) )