SynologyDSM/SynologyDSM.py
def bytes_to_readable(num):
        """Converts bytes to a human readable format"""
        if num < 512:
            return "0 Kb"
        elif num < 1024:
            return "1 Kb"

        for unit in ['', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb', 'Zb']:
            if abs(num) < 1024.0:
                return "%3.1f%s" % (num, unit)
            num /= 1024.0
        return "%.1f%s" % (num, 'Yb')
def bytes_to_readable(num):
        if num < 512:
            return "0 Kb"
        elif num < 1024:
            return "1 Kb"

        for unit in ['', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb', 'Zb']:
            if abs(num) < 1024.0:
                return "%3.1f%s" % (num, unit)
            num /= 1024.0
        return "%.1f%s" % (num, 'Yb')
def bytes_to_readable ( num ) : if num < 512 : return "0 Kb" elif num < 1024 : return "1 Kb" for unit in [ '' , 'Kb' , 'Mb' , 'Gb' , 'Tb' , 'Pb' , 'Eb' , 'Zb' ] : if abs ( num ) < 1024.0 : return "%3.1f%s" % ( num , unit ) num /= 1024.0 return "%.1f%s" % ( num , 'Yb' )
Converts bytes to a human readable format
Converts bytes to a human readable format