parameters: (uinput, ibase=0)
docstring: Format file size utility, it converts file size into KB, MB, GB, TB, PB units
docstring_summary: Format file size utility, it converts file size into KB, MB, GB, TB, PB units
docstring_tokens: Format file size utility it converts file size into KB MB GB TB PB units
function: def size_format(uinput, ibase=0):
      """
      Format file size utility, it converts file size into KB, MB, GB, TB, PB units
      """
      if  not ibase:
          return uinput
      try:
          num = float(uinput)
      except Exception as _exc:
          return uinput
      if  ibase == 2.: # power of 2
          base  = 1024.
          xlist = ['', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB']
      else: # default base is 10
          base  = 1000.
          xlist = ['', 'KB', 'MB', 'GB', 'TB', 'PB']
      for xxx in xlist:
          if  num < base:
              return "%3.1f%s" % (num, xxx)
          num /= base
function_tokens: def size_format ( uinput , ibase = 0 ) : if not ibase : return uinput try : num = float ( uinput ) except Exception as _exc : return uinput if ibase == 2. : # power of 2 base = 1024. xlist = [ '' , 'KiB' , 'MiB' , 'GiB' , 'TiB' , 'PiB' ] else : # default base is 10 base = 1000. xlist = [ '' , 'KB' , 'MB' , 'GB' , 'TB' , 'PB' ] for xxx in xlist : if num < base : return "%3.1f%s" % ( num , xxx ) num /= base