def human_time(timespan, precision=<NUM_LIT:3>):
if timespan >= <NUM_LIT>:<EOL><INDENT>def _format_long_time(time):<EOL><INDENT>suffixes = ('<STR_LIT:d>', '<STR_LIT:h>', '<STR_LIT:m>', '<STR_LIT:s>')<EOL>lengths = (<NUM_LIT>*<NUM_LIT>*<NUM_LIT>, <NUM_LIT>*<NUM_LIT>, <NUM_LIT>, <NUM_LIT:1>)<EOL>for suffix, length in zip(suffixes, lengths):<EOL><INDENT>value = int(time / length)<EOL>if value > <NUM_LIT:0>:<EOL><INDENT>time %= length<EOL>yield '<STR_LIT>' % (value, suffix)<EOL><DEDENT>if time < <NUM_LIT:1>:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT>return '<STR_LIT:U+0020>'.join(_format_long_time(timespan))<EOL><DEDENT>else:<EOL><INDENT>units = ['<STR_LIT:s>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>if hasattr(sys.stdout, '<STR_LIT>') and sys.stdout.encoding == '<STR_LIT>':<EOL><INDENT>try:<EOL><INDENT>units[<NUM_LIT:2>] = b'<STR_LIT>'.decode('<STR_LIT:utf-8>')<EOL><DEDENT>except UnicodeEncodeError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>scale = [<NUM_LIT:1.0>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>]<EOL>if timespan > <NUM_LIT:0.0>:<EOL><INDENT>order = min(-int(math.floor(math.log10(timespan)) // <NUM_LIT:3>), <NUM_LIT:3>)<EOL><DEDENT>else:<EOL><INDENT>order = <NUM_LIT:3><EOL><DEDENT>return '<STR_LIT>' % (precision, timespan * scale[order], units[order])<EOL><DEDENT>
Formats the timespan in a human readable format