<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> import base64 <EOL> import urllib <EOL> try : <EOL> import simplejson as json <EOL> except ImportError : <EOL> try : <EOL> import json <EOL> except ImportError : <EOL> raise RuntimeError ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> assert hasattr ( json , '<STR_LIT>' ) and hasattr ( json , '<STR_LIT>' ) , '<STR_LIT>' <EOL> def encode ( value , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> kwargs . setdefault ( '<STR_LIT>' , ( '<STR_LIT:U+002C>' , '<STR_LIT::>' ) ) <EOL> return json . dumps ( value , * args , ** kwargs ) . replace ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> def decode ( value , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( value , str ) : <EOL> value = value . decode ( '<STR_LIT:utf-8>' ) <EOL> assert isinstance ( value , unicode ) <EOL> return json . loads ( value , * args , ** kwargs ) <EOL> def b64encode ( value , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> return base64 . b64encode ( encode ( value , * args , ** kwargs ) ) <EOL> def b64decode ( value , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> return decode ( base64 . b64decode ( value ) , * args , ** kwargs ) <EOL> def quote ( value , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> return urllib . quote ( encode ( value , * args , ** kwargs ) ) <EOL> def unquote ( value , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> return decode ( urllib . unquote ( value ) , * args , ** kwargs ) </s>
