Skip to main content

Project Logo

The Lupaxa Developers Toolbox
Part of The Lupaxa Project


lupaxa-convert-size

Convert file sizes between IEC (binary) and SI (decimal) units, including bits, nibbles, and bytes.

Built for scripts and tools used by The Lupaxa Project.

Features

  • Convert between IEC units (B, KiB, … QiB, bit, Kibit, … Qibit) using a 1024 scaler
  • Convert between SI units (B, kB, … QB, bit, kbit, … Qbit) using a 1000 scaler
  • Convert between bits, nibbles, and bytes in the same family (8 bits = 2 nibbles = 1 byte)
  • Look up the full name of a unit from its abbreviation
  • Case-insensitive unit codes
  • Fully typed, linted, formatted, and tested

Installation

From PyPI

pip install lupaxa-convert-size

From source (development mode)

pip install -e ".[dev]"

Requires Python 3.10+. No runtime dependencies.

Usage

from lupaxa.convert_size import convert_size, get_name_from_code

convert_size(1024, "B", "KiB")
# 1.0

convert_size(1, "GiB", "MiB")
# 1024.0

convert_size(2000, "B", "kB", si_units=True)
# 2.0

convert_size(1, "KiB", "Kibit")
# 8.0

convert_size(1, "B", "nibble")
# 2.0

get_name_from_code("MiB")
# "Mebibyte"

get_name_from_code("kB", si_units=True)
# "Kilobyte"

A walkthrough of the same API is in demo.py in the source repository.

Development

Clone the repository and install with Make:

make init                # first-time makefile-skills checkout
make python-install-dev  # editable install with [dev]
make python-check        # lint, type-check, and test
make mkdocs-serve        # local docs site

Documentation: https://convert-size.thelupaxaproject.org/.

The Lupaxa Project Footer

Download files

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

Source Distribution

lupaxa_convert_size-0.1.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

lupaxa_convert_size-0.1.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file lupaxa_convert_size-0.1.0.tar.gz.

File metadata

  • Download URL: lupaxa_convert_size-0.1.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for lupaxa_convert_size-0.1.0.tar.gz
Algorithm Hash digest
SHA256 de15e90ff80acfb72ee96859c354b613c04b7a7a54e48c37c6cbf0632f52b959
MD5 52987bbe28eecdadab2cac5c2116b7b8
BLAKE2b-256 9c8500438adb673c4d28a762f69302c27816cea6fd65810e0024329382f1b171

See more details on using hashes here.

Provenance

The following attestation bundles were made for lupaxa_convert_size-0.1.0.tar.gz:

Publisher: generate-release.yml on lupaxa-developers-toolbox/convert-size

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lupaxa_convert_size-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for lupaxa_convert_size-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9996d092ea0b3e38b6c24011f8e2a566de164c47ed62115c81f37aafefa23265
MD5 ea90a987f89521b2604debaf8b085f05
BLAKE2b-256 a2b5599c730e334c70d510ad337b2a9f4ea59192f7177c5cf68e71ca0c7957f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for lupaxa_convert_size-0.1.0-py3-none-any.whl:

Publisher: generate-release.yml on lupaxa-developers-toolbox/convert-size

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page