<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> import sys <EOL> import time <EOL> STREAM = sys . stderr <EOL> BAR_TEMPLATE = '<STR_LIT>' <EOL> MILL_TEMPLATE = '<STR_LIT>' <EOL> DOTS_CHAR = '<STR_LIT:.>' <EOL> BAR_FILLED_CHAR = '<STR_LIT:#>' <EOL> BAR_EMPTY_CHAR = '<STR_LIT:U+0020>' <EOL> MILL_CHARS = [ '<STR_LIT:|>' , '<STR_LIT:/>' , '<STR_LIT:->' , '<STR_LIT:\\>' ] <EOL> ETA_INTERVAL = <NUM_LIT:1> <EOL> ETA_SMA_WINDOW = <NUM_LIT:9> <EOL> def bar ( it , label = '<STR_LIT>' , width = <NUM_LIT:32> , hide = False , empty_char = BAR_EMPTY_CHAR , filled_char = BAR_FILLED_CHAR ) : <EOL> """<STR_LIT>""" <EOL> def _show ( _i ) : <EOL> if ( time . time ( ) - bar . etadelta ) > ETA_INTERVAL : <EOL> bar . etadelta = time . time ( ) <EOL> bar . ittimes = bar . ittimes [ - ETA_SMA_WINDOW : ] + [ - ( bar . start - time . time ( ) ) / ( _i + <NUM_LIT:1> ) ] <EOL> bar . eta = sum ( bar . ittimes ) / float ( len ( bar . ittimes ) ) * ( count - _i ) <EOL> bar . etadisp = time . strftime ( '<STR_LIT>' , time . gmtime ( bar . eta ) ) <EOL> x = int ( width * _i / count ) <EOL> if not hide : <EOL> STREAM . write ( BAR_TEMPLATE % ( <EOL> label , filled_char * x , empty_char * ( width - x ) , _i , count , bar . etadisp ) ) <EOL> STREAM . flush ( ) <EOL> count = len ( it ) <EOL> bar . start = time . time ( ) <EOL> bar . ittimes = [ ] <EOL> bar . eta = <NUM_LIT:0> <EOL> bar . etadelta = time . time ( ) <EOL> bar . etadisp = time . strftime ( '<STR_LIT>' , time . gmtime ( bar . eta ) ) <EOL> if count : <EOL> _show ( <NUM_LIT:0> ) <EOL> for i , item in enumerate ( it ) : <EOL> yield item <EOL> _show ( i + <NUM_LIT:1> ) <EOL> if not hide : <EOL> STREAM . write ( '<STR_LIT:\n>' ) <EOL> STREAM . flush ( ) <EOL> def dots ( it , label = '<STR_LIT>' , hide = False ) : <EOL> """<STR_LIT>""" <EOL> count = <NUM_LIT:0> <EOL> if not hide : <EOL> STREAM . write ( label ) <EOL> for item in it : <EOL> if not hide : <EOL> STREAM . write ( DOTS_CHAR ) <EOL> sys . stderr . flush ( ) <EOL> count += <NUM_LIT:1> <EOL> yield item <EOL> STREAM . write ( '<STR_LIT:\n>' ) <EOL> STREAM . flush ( ) <EOL> def mill ( it , label = '<STR_LIT>' , hide = False , ) : <EOL> """<STR_LIT>""" <EOL> def _mill_char ( _i ) : <EOL> if _i == <NUM_LIT:100> : <EOL> return '<STR_LIT:U+0020>' <EOL> else : <EOL> return MILL_CHARS [ _i % len ( MILL_CHARS ) ] <EOL> def _show ( _i ) : <EOL> if not hide : <EOL> STREAM . write ( MILL_TEMPLATE % ( <EOL> label , _mill_char ( _i ) , _i , count ) ) <EOL> STREAM . flush ( ) <EOL> count = len ( it ) <EOL> if count : <EOL> _show ( <NUM_LIT:0> ) <EOL> for i , item in enumerate ( it ) : <EOL> yield item <EOL> _show ( i + <NUM_LIT:1> ) <EOL> if not hide : <EOL> STREAM . write ( '<STR_LIT:\n>' ) <EOL> STREAM . flush ( ) </s>
