<s> from itertools import chain <EOL> from functools import update_wrapper <EOL> from flask import Response , json <EOL> def fs_path_to_url_path ( path ) : <EOL> segments = path . strip ( '<STR_LIT:/>' ) . split ( '<STR_LIT:/>' ) <EOL> if segments == [ '<STR_LIT>' ] : <EOL> segments = [ ] <EOL> segments . insert ( <NUM_LIT:0> , '<STR_LIT:root>' ) <EOL> return '<STR_LIT::>' . join ( segments ) <EOL> def eventstream ( f ) : <EOL> def new_func ( * args , ** kwargs ) : <EOL> def generate ( ) : <EOL> for event in chain ( f ( * args , ** kwargs ) , ( None , ) ) : <EOL> yield '<STR_LIT>' % json . dumps ( event ) <EOL> return Response ( generate ( ) , mimetype = '<STR_LIT>' , <EOL> direct_passthrough = True ) <EOL> return update_wrapper ( new_func , f ) </s>
