<s> import base64 <EOL> def get_lti_value ( key , tool_provider , encoding = None ) : <EOL> """<STR_LIT>""" <EOL> lti_value = None <EOL> if "<STR_LIT>" in key : <EOL> lti_value = tool_provider . custom_params [ key ] <EOL> if "<STR_LIT>" in key : <EOL> lti_value = tool_provider . ext_params [ key ] <EOL> if not lti_value : <EOL> try : <EOL> lti_value = getattr ( tool_provider , key ) <EOL> except AttributeError : <EOL> print "<STR_LIT>" % key <EOL> if encoding == "<STR_LIT>" : <EOL> if isinstance ( lti_value , list ) : <EOL> lti_value = [ base64 . b64decode ( val ) for val in lti_value ] <EOL> else : <EOL> lti_value = base64 . b64decode ( lti_value ) <EOL> if encoding == "<STR_LIT:utf8>" : lti_value = lti_value . decode ( '<STR_LIT:utf-8>' ) <EOL> if encoding == "<STR_LIT>" : lti_value = lti_value . decode ( '<STR_LIT>' ) <EOL> return lti_value </s>
