<s> from django . utils . functional import Promise <EOL> from django . utils . encoding import force_unicode <EOL> def resolve_promise ( o ) : <EOL> if isinstance ( o , dict ) : <EOL> for k , v in o . items ( ) : <EOL> o [ k ] = resolve_promise ( v ) <EOL> elif isinstance ( o , ( list , tuple ) ) : <EOL> o = [ resolve_promise ( x ) for x in o ] <EOL> elif isinstance ( o , Promise ) : <EOL> try : <EOL> o = force_unicode ( o ) <EOL> except : <EOL> try : <EOL> o = [ resolve_promise ( x ) for x in o ] <EOL> except : <EOL> raise Exception ( '<STR_LIT>' % o ) <EOL> elif callable ( o ) : <EOL> o = o ( ) <EOL> return o </s>
