Skip to main content

Convert bytes to human-readable file sizes and back

Project description

philiprehberger-filesize

Convert bytes to human-readable file sizes and back.

Installation

pip install philiprehberger-filesize

Usage

from philiprehberger_filesize import humanize, parse, is_larger_than

humanize(1536)                  # "1.5 KB"
humanize(1073741824)            # "1.0 GB"
humanize(1024, binary=True)     # "1.0 KiB"

parse("1.5 GB")                 # 1500000000
parse("1 KiB")                  # 1024

is_larger_than(5000000, "1 MB") # True

API

  • humanize(size, binary=False, precision=1) — Bytes to human string
  • format_bytes(size, binary=False, precision=2) — Alias with precision=2
  • parse(text) — Human string to bytes
  • is_larger_than(size, threshold) — Compare size to human string

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

philiprehberger_filesize-0.1.1.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

philiprehberger_filesize-0.1.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file philiprehberger_filesize-0.1.1.tar.gz.

File metadata

  • Download URL: philiprehberger_filesize-0.1.1.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for philiprehberger_filesize-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7df30098b54b8681734cc5e4d9ec2a3c9210488d82117928f292fa84fd2c4b02
MD5 95261a1664706b572a81025288821e8d
BLAKE2b-256 f84471199f4d7c9b5205c7f09d3558cbee9ec5ca500c0edadd04541ff5077d54

See more details on using hashes here.

File details

Details for the file philiprehberger_filesize-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_filesize-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ab3b08706234ef74049ee992cc0539c0e4be2f70120b315816d9ab8c904bc071
MD5 d90031e50dc44ae0b9263009dc8c91db
BLAKE2b-256 584bf02df7fc0e5df34743322cbbfb0c8c6ca329bf326b7724a412356c43736d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page