Metadata-Version: 2.4
Name: philiprehberger-filesize
Version: 0.1.2
Summary: Convert bytes to human-readable file sizes and back
Project-URL: Homepage, https://github.com/philiprehberger/py-filesize#readme
Project-URL: Repository, https://github.com/philiprehberger/py-filesize
Project-URL: Issues, https://github.com/philiprehberger/py-filesize/issues
Project-URL: Changelog, https://github.com/philiprehberger/py-filesize/blob/main/CHANGELOG.md
Author: Philip Rehberger
License-Expression: MIT
License-File: LICENSE
Keywords: bytes,filesize,format,human-readable,size
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# philiprehberger-filesize

[![Tests](https://github.com/philiprehberger/py-filesize/actions/workflows/publish.yml/badge.svg)](https://github.com/philiprehberger/py-filesize/actions/workflows/publish.yml)
[![PyPI version](https://img.shields.io/pypi/v/philiprehberger-filesize.svg)](https://pypi.org/project/philiprehberger-filesize/)
[![License](https://img.shields.io/github/license/philiprehberger/py-filesize)](LICENSE)

Convert bytes to human-readable file sizes and back.

## Installation

```bash
pip install philiprehberger-filesize
```

## Usage

```python
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
