kitir/_libs/byte_utils.py
def bytes2human(n, frmt='%(value).1f%(symbol)s', symbols='customary'):
    """
    Convert n bytes into a human readable string based on format.
    symbols can be either "customary", "customary_ext", "iec" or "iec_ext",
    see: http://goo.gl/kTQMs
    """
    # Bytes-to-human / human-to-bytes converter.
    # Based on: http://goo.gl/kTQMs
    # Working with Python 2.x and 3.x.
    #
    # Author: Giampaolo Rodola' <g.rodola [AT] gmail [DOT] com>
    # License: MIT
    # copied from: http://code.activestate.com/recipes/578019-bytes-to-human-human-to-bytes-converter/?in=user-4178764
    n = int(n)
    if n < 0:
        raise ValueError("n < 0")
    symbols = SYMBOLS[symbols]
    prefix = {}
    for i, s in enumerate(symbols[1:]):
        prefix[s] = 1 << (i + 1) * 10
    for symbol in reversed(symbols[1:]):
        if n >= prefix[symbol]:
            value = float(n) / prefix[symbol]
            return frmt % locals()
    return frmt % dict(symbol=symbols[0], value=n)

    Convert n bytes into a human readable string based on format.
    symbols can be either "customary", "customary_ext", "iec" or "iec_ext",
    see: http://goo.gl/kTQMs
    
Convert n bytes into a human readable string based on format.
Convert n bytes into a human readable string based on format .
def bytes2human(n, frmt='%(value).1f%(symbol)s', symbols='customary'):
     Author: Giampaolo Rodola' <g.rodola [AT] gmail [DOT] com>
     License: MIT
     copied from: http://code.activestate.com/recipes/578019-bytes-to-human-human-to-bytes-converter/?in=user-4178764
    n = int(n)
    if n < 0:
        raise ValueError("n < 0")
    symbols = SYMBOLS[symbols]
    prefix = {}
    for i, s in enumerate(symbols[1:]):
        prefix[s] = 1 << (i + 1) * 10
    for symbol in reversed(symbols[1:]):
        if n >= prefix[symbol]:
            value = float(n) / prefix[symbol]
            return frmt % locals()
    return frmt % dict(symbol=symbols[0], value=n)
def bytes2human ( n , frmt = '%(value).1f%(symbol)s' , symbols = 'customary' ) : n = int ( n ) if n < 0 : raise ValueError ( "n < 0" ) symbols = SYMBOLS [ symbols ] prefix = { } for i , s in enumerate ( symbols [ 1 : ] ) : prefix [ s ] = 1 << ( i + 1 ) * 10 for symbol in reversed ( symbols [ 1 : ] ) : if n >= prefix [ symbol ] : value = float ( n ) / prefix [ symbol ] return frmt % locals ( ) return frmt % dict ( symbol = symbols [ 0 ] , value = n )
Convert n bytes into a human readable string based on format.
Convert n bytes into a human readable string based on format .
"""
    Convert n bytes into a human readable string based on format.
    symbols can be either "customary", "customary_ext", "iec" or "iec_ext",
    see: http://goo.gl/kTQMs
    """ # Bytes-to-human / human-to-bytes converter. # Based on: http://goo.gl/kTQMs # Working with Python 2.x and 3.x. # # Author: Giampaolo Rodola' <g.rodola [AT] gmail [DOT] com> # License: MIT # copied from: http://code.activestate.com/recipes/578019-bytes-to-human-human-to-bytes-converter/?in=user-4178764
n
frmt
symbols