<s> from itertools import islice <EOL> from elasticsearch . serializer import JSONSerializer <EOL> def to_json ( data ) : <EOL> """<STR_LIT>""" <EOL> return JSONSerializer ( ) . dumps ( data ) <EOL> def chunked ( iterable , n ) : <EOL> """<STR_LIT>""" <EOL> iterable = iter ( iterable ) <EOL> while <NUM_LIT:1> : <EOL> t = tuple ( islice ( iterable , n ) ) <EOL> if t : <EOL> yield t <EOL> else : <EOL> return <EOL> def format_explanation ( explanation , indent = '<STR_LIT:U+0020>' , indent_level = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if not explanation : <EOL> return '<STR_LIT>' <EOL> line = ( '<STR_LIT>' % ( ( indent * indent_level ) , <EOL> explanation [ '<STR_LIT:description>' ] , <EOL> explanation [ '<STR_LIT:value>' ] ) ) <EOL> if '<STR_LIT>' in explanation : <EOL> details = '<STR_LIT:\n>' . join ( <EOL> [ format_explanation ( subtree , indent , indent_level + <NUM_LIT:1> ) <EOL> for subtree in explanation [ '<STR_LIT>' ] ] ) <EOL> return line + '<STR_LIT:\n>' + details <EOL> return line </s>
