# fw-utils
Helper utilities for common tasks including pluralization, formatting and
parsing human-readable file-sizes/time-deltas, creating attribute-accessible
dictionaries and opening files.
## Installation
Add as a `poetry` dependency to your project:
```bash
poetry add fw-utils
```
## Usage
```python
import fw_utils
# common string formatters
fw_utils.pluralize("file") == "files"
fw_utils.quantify(3, "file") == "3 files"
fw_utils.hrsize(1024) == "1.0K"
fw_utils.hrtime(90) == "1h 30m"
# get a dictionary with keys accessible as attrs
data = fw_utils.attrify({"key": "value"})
data.key == "value"
# File works with str|Path|file-like objects alike
with fw_utils.BinFile("/tmp/test.txt", write=True) as file:
file.write(b"text")
```
## Development
Install the project using `poetry` and enable `pre-commit`:
```bash
poetry install
pre-commit install
```
## License
[![MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE)
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/flywheel-io/tools/lib/fw-utils",
"name": "fw-utils",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": "Flywheel, helper, utility",
"author": "Flywheel",
"author_email": "support@flywheel.io",
"download_url": null,
"platform": null,
"description": "# fw-utils\n\nHelper utilities for common tasks including pluralization, formatting and\nparsing human-readable file-sizes/time-deltas, creating attribute-accessible\ndictionaries and opening files.\n\n## Installation\n\nAdd as a `poetry` dependency to your project:\n\n```bash\npoetry add fw-utils\n```\n\n## Usage\n\n```python\nimport fw_utils\n\n# common string formatters\nfw_utils.pluralize(\"file\") == \"files\"\nfw_utils.quantify(3, \"file\") == \"3 files\"\nfw_utils.hrsize(1024) == \"1.0K\"\nfw_utils.hrtime(90) == \"1h 30m\"\n\n# get a dictionary with keys accessible as attrs\ndata = fw_utils.attrify({\"key\": \"value\"})\ndata.key == \"value\"\n\n# File works with str|Path|file-like objects alike\nwith fw_utils.BinFile(\"/tmp/test.txt\", write=True) as file:\n file.write(b\"text\")\n```\n\n## Development\n\nInstall the project using `poetry` and enable `pre-commit`:\n\n```bash\npoetry install\npre-commit install\n```\n\n## License\n\n[![MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Common Flywheel helper utilities.",
"version": "5.0.3",
"project_urls": {
"Documentation": "https://gitlab.com/flywheel-io/tools/lib/fw-utils",
"Homepage": "https://gitlab.com/flywheel-io/tools/lib/fw-utils",
"Repository": "https://gitlab.com/flywheel-io/tools/lib/fw-utils"
},
"split_keywords": [
"flywheel",
" helper",
" utility"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0a18e87cdae8f8821a5f9684facf7e6ad116d826cac673700d0edc112778dae2",
"md5": "9df80f3a9e53a99ad2c6165d22d8c17b",
"sha256": "0c7fae1e97bb92052a47f24c83edf294dbcd695d96547f44345d824d08336b46"
},
"downloads": -1,
"filename": "fw_utils-5.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9df80f3a9e53a99ad2c6165d22d8c17b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 24560,
"upload_time": "2024-09-17T20:32:13",
"upload_time_iso_8601": "2024-09-17T20:32:13.725567Z",
"url": "https://files.pythonhosted.org/packages/0a/18/e87cdae8f8821a5f9684facf7e6ad116d826cac673700d0edc112778dae2/fw_utils-5.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-17 20:32:13",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "flywheel-io",
"gitlab_project": "tools",
"lcname": "fw-utils"
}