def humansize(nbytes):
   """ 
   Translates a size in bytes to a human readable size format

   :param int nbytes: integer of size of torrent file
   :return: size in bytes in a human readable format
   :rtype: str
   """
   suffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']
   i = 0
   while nbytes >= 1024 and i < len(suffixes)-1:
      nbytes /= 1024.
      i += 1
   f = ('%.2f' % nbytes).rstrip('0').rstrip('.')
   return '{} {}'.format(f, suffixes[i])