File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66
77from humanize .i18n import gettext as _
88
9-
109_SUFFIXES = {
1110 "decimal" : (
1211 _ (" kB" ),
@@ -40,8 +39,7 @@ def naturalsize(
4039 binary : bool = False ,
4140 format : str = "%.1f" ,
4241) -> str :
43- """
44- Format a number of bytes like a human-readable file size.
42+ """Format a number of bytes like a human-readable file size.
4543
4644 Examples:
4745 >>> naturalsize(42)
@@ -59,7 +57,6 @@ def naturalsize(
5957 :param format: Numeric format string.
6058 :return: Human-readable file size.
6159 """
62-
6360 try :
6461 bytes_value = float (value )
6562 except (TypeError , ValueError ):
@@ -76,10 +73,6 @@ def naturalsize(
7673
7774 value = bytes_value / base ** exp
7875
79- suffix = (
80- _SUFFIXES ["binary" ][exp - 1 ]
81- if binary
82- else _SUFFIXES ["decimal" ][exp - 1 ]
83- )
76+ suffix = _SUFFIXES ["binary" ][exp - 1 ] if binary else _SUFFIXES ["decimal" ][exp - 1 ]
8477
8578 return (format % value ) + suffix
You can’t perform that action at this time.
0 commit comments