make courseware/capa/util.py contextualize_text return gracefully if text = None

This commit is contained in:
ichuang
2012-05-17 22:39:20 -04:00
parent 5e8fbcdc8d
commit 22c75cf748

View File

@@ -1,6 +1,7 @@
def contextualize_text(text, context): # private
''' Takes a string with variables. E.g. $a+$b.
Does a substitution of those variables from the context '''
if not text: return text
for key in sorted(context, lambda x,y:cmp(len(y),len(x))):
text=text.replace('$'+key, str(context[key]))
return text