<s> import functools <EOL> import operator <EOL> def listify ( f ) : <EOL> """<STR_LIT>""" <EOL> @ functools . wraps ( f ) <EOL> def listify_helper ( * args , ** kwargs ) : <EOL> output = f ( * args , ** kwargs ) <EOL> if kwargs . get ( '<STR_LIT>' ) : <EOL> return output <EOL> elif output is not None : <EOL> return list ( output ) <EOL> else : <EOL> return [ ] <EOL> return listify_helper <EOL> def dictify ( f ) : <EOL> """<STR_LIT>""" <EOL> @ functools . wraps ( f ) <EOL> def dictify_helper ( * args , ** kwargs ) : <EOL> output = f ( * args , ** kwargs ) <EOL> if kwargs . get ( '<STR_LIT>' ) : <EOL> return output <EOL> elif output is not None : <EOL> return dict ( output ) <EOL> else : <EOL> return { } <EOL> return dictify_helper <EOL> output_templates = { <EOL> '<STR_LIT>' : """<STR_LIT>""" , <EOL> '<STR_LIT>' : """<STR_LIT>""" , <EOL> '<STR_LIT>' : """<STR_LIT>""" <EOL> } <EOL> output_templates = { k : "<STR_LIT:\n>" . join ( [ line . lstrip ( ) for line in v [ <NUM_LIT:1> : ] . split ( '<STR_LIT:\n>' ) ] ) <EOL> for ( k , v ) in output_templates . items ( ) } <EOL> def dict_merge ( * args ) : <EOL> d = { } <EOL> keys = reduce ( operator . add , ( k . keys ( ) for k in args ) ) <EOL> for key in keys : <EOL> d [ key ] = [ ] <EOL> for k in args : <EOL> if key in k : <EOL> d [ key ] += [ k [ key ] ] <EOL> if len ( d [ key ] ) == <NUM_LIT:1> : <EOL> d [ key ] = d [ key ] [ <NUM_LIT:0> ] <EOL> return d </s>
