Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def naturalsize(number, type=None):
""" Return a humanized (and translated) file size. """
with humanize.i18n.django_language():
if type is None:
return humanize.naturalsize(number)
if type in ('bin', 'binary'):
return humanize.naturalsize(number, binary=True)
if type in ('gnu', 'GNU'):
return humanize.naturalsize(number, gnu=True)