backuppc_clone.misc   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 3

1 Function

Rating   Name   Duplication   Size   Complexity  
A sizeof_fmt() 0 15 3
1
def sizeof_fmt(num: int, suffix: str = 'B') -> str:
2
    """
3
    Returns the size in bytes in human-readable format.
4
5
    @param int num: The number of bytes.
6
    @param str suffix: The suffix.
7
8
    :rtype: str
9
    """
10
    for unit in ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi']:
11
        if abs(num) < 1024.0:
12
            return '%3.1f%s%s' % (num, unit, suffix)
13
        num /= 1024.0
14
15
    return '%.1f%s%s' % (num, 'Yi', suffix)
16