<s> """<STR_LIT>""" <EOL> def export ( values ) : <EOL> o = [ ] <EOL> for k , v in sorted ( values . items ( ) ) : <EOL> o . append ( '<STR_LIT>' % ( escape ( k ) , build_value ( v ) ) ) <EOL> return '<STR_LIT:\n>' . join ( o ) <EOL> class ExportedMap ( object ) : <EOL> def __init__ ( self , label , value ) : <EOL> self . label = label <EOL> self . value = value <EOL> def __str__ ( self ) : <EOL> o = [ '<STR_LIT>' % escape ( self . label ) ] <EOL> for k , v in sorted ( self . value . items ( ) ) : <EOL> o . append ( '<STR_LIT>' % ( escape ( k ) , escape ( v ) ) ) <EOL> return '<STR_LIT:U+0020>' . join ( o ) <EOL> class ExportedList ( object ) : <EOL> def __init__ ( self , value ) : <EOL> self . value = value <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT:/>' . join ( [ escape ( v ) for v in self . value ] ) <EOL> class ExportedCallable ( object ) : <EOL> def __init__ ( self , callable ) : <EOL> self . callable = callable <EOL> def __str__ ( self ) : <EOL> return make_value ( self . callable ( ) ) <EOL> def build_value ( value ) : <EOL> """<STR_LIT>""" <EOL> if type ( value ) is type ( tuple ( ) ) and type ( value [ <NUM_LIT:1> ] ) is type ( dict ( ) ) : <EOL> return ExportedMap ( label = value [ <NUM_LIT:0> ] , value = value [ <NUM_LIT:1> ] ) <EOL> elif type ( value ) is type ( tuple ( ) ) or type ( value ) is type ( list ( ) ) : <EOL> return ExportedList ( value ) <EOL> elif callable ( value ) : <EOL> return ExportedCallable ( value ) <EOL> else : <EOL> return escape ( value ) <EOL> def escape ( value ) : <EOL> return str ( value ) . replace ( '<STR_LIT:\\>' , '<STR_LIT>' ) . replace ( '<STR_LIT::>' , '<STR_LIT>' ) . replace ( '<STR_LIT:U+0020>' , '<STR_LIT:->' ) </s>
