<s> import bitmath <EOL> import argparse <EOL> import progressbar . widgets <EOL> def BitmathType ( bmstring ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> argvalue = bitmath . parse_string ( bmstring ) <EOL> except ValueError : <EOL> raise argparse . ArgumentTypeError ( "<STR_LIT>" % <EOL> bmstring ) <EOL> else : <EOL> return argvalue <EOL> class BitmathFileTransferSpeed ( progressbar . widgets . Widget ) : <EOL> """<STR_LIT>""" <EOL> __slots__ = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def __init__ ( self , system = bitmath . NIST , format = "<STR_LIT>" ) : <EOL> self . system = system <EOL> self . format = format <EOL> def update ( self , pbar ) : <EOL> """<STR_LIT>""" <EOL> if pbar . seconds_elapsed < <NUM_LIT> or pbar . currval < <NUM_LIT> : <EOL> scaled = bitmath . Byte ( ) <EOL> else : <EOL> speed = pbar . currval / pbar . seconds_elapsed <EOL> scaled = bitmath . Byte ( speed ) . best_prefix ( system = self . system ) <EOL> return scaled . format ( self . format ) </s>
