{"id":22316670,"url":"https://github.com/developerstoolbox/convert-size-package","last_synced_at":"2025-07-29T12:30:30.931Z","repository":{"id":241283890,"uuid":"804858713","full_name":"DevelopersToolbox/convert-size-package","owner":"DevelopersToolbox","description":"Convert between various sizes.","archived":false,"fork":false,"pushed_at":"2025-07-21T05:43:01.000Z","size":205,"stargazers_count":1,"open_issues_count":4,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-21T07:25:26.686Z","etag":null,"topics":["converter","pypi","pypi-package","python","python-package","wolfsoftware"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DevelopersToolbox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":".github/CODEOWNERS","security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["WolfSoftware","TGWolf"]}},"created_at":"2024-05-23T12:10:21.000Z","updated_at":"2025-07-21T05:40:13.000Z","dependencies_parsed_at":"2024-08-26T05:58:03.488Z","dependency_job_id":"c8d8a110-6567-4cdb-bcfa-9958cb65a7f5","html_url":"https://github.com/DevelopersToolbox/convert-size-package","commit_stats":null,"previous_names":["developerstoolbox/convert-size-package"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/DevelopersToolbox/convert-size-package","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevelopersToolbox%2Fconvert-size-package","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevelopersToolbox%2Fconvert-size-package/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevelopersToolbox%2Fconvert-size-package/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevelopersToolbox%2Fconvert-size-package/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DevelopersToolbox","download_url":"https://codeload.github.com/DevelopersToolbox/convert-size-package/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevelopersToolbox%2Fconvert-size-package/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267686334,"owners_count":24127715,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["converter","pypi","pypi-package","python","python-package","wolfsoftware"],"created_at":"2024-12-03T23:07:24.995Z","updated_at":"2025-07-29T12:30:30.672Z","avatar_url":"https://github.com/DevelopersToolbox.png","language":"Python","readme":"\u003c!-- markdownlint-disable --\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/\"\u003e\n        \u003cimg src=\"https://cdn.wolfsoftware.com/assets/images/github/organisations/developerstoolbox/black-and-white-circle-256.png\" alt=\"DevelopersToolbox logo\" /\u003e\n    \u003c/a\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/convert-size-package/actions/workflows/cicd.yml\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/DevelopersToolbox/convert-size-package/cicd.yml?branch=master\u0026label=build%20status\u0026style=for-the-badge\" alt=\"Github Build Status\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/convert-size-package/blob/master/LICENSE.md\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/license/DevelopersToolbox/convert-size-package?color=blue\u0026label=License\u0026style=for-the-badge\" alt=\"License\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/convert-size-package\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/created-at/DevelopersToolbox/convert-size-package?color=blue\u0026label=Created\u0026style=for-the-badge\" alt=\"Created\"\u003e\n    \u003c/a\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/convert-size-package/releases/latest\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/v/release/DevelopersToolbox/convert-size-package?color=blue\u0026label=Latest%20Release\u0026style=for-the-badge\" alt=\"Release\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/convert-size-package/releases/latest\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/release-date/DevelopersToolbox/convert-size-package?color=blue\u0026label=Released\u0026style=for-the-badge\" alt=\"Released\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/convert-size-package/releases/latest\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/commits-since/DevelopersToolbox/convert-size-package/latest.svg?color=blue\u0026style=for-the-badge\" alt=\"Commits since release\"\u003e\n    \u003c/a\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/convert-size-package/blob/master/.github/CODE_OF_CONDUCT.md\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Code%20of%20Conduct-blue?style=for-the-badge\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/convert-size-package/blob/master/.github/CONTRIBUTING.md\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Contributing-blue?style=for-the-badge\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/convert-size-package/blob/master/.github/SECURITY.md\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Report%20Security%20Concern-blue?style=for-the-badge\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/convert-size-package/issues\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Get%20Support-blue?style=for-the-badge\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n## Overview\n\nThe File Size Converter module provides functions for converting file sizes between different units in both IEC (binary)\nand SI (decimal) formats. It includes functionality for getting the full name of a unit from its abbreviation and\nconverting sizes between units.\n\n## Features\n\n- Convert sizes between different IEC units (e.g., Bytes to Kibibytes).\n- Convert sizes between different SI units (e.g., Bytes to Kilobytes).\n- Retrieve the full name of a unit from its abbreviation.\n- Support for both IEC (binary) and SI (decimal) unit systems.\n\n## Installation\n\n```shell\npip install wolfsoftware.convert-size\n```\n\n## Usage\n\n### Importing the Module\n\n```python\nimport wolfsoftware.convert_size as fsc\n```\n\n### Converting Sizes\n\nTo convert a size between different units, use the `convert_size` function. You can specify whether to use SI units by setting the `si_units` parameter.\n\n```python\n# IEC conversion example\nsize_in_gib = fsc.convert_size(1024, 'MiB', 'GiB')\nprint(size_in_gib)  # Output: 1.0\n\n# SI conversion example\nsize_in_gb = fsc.convert_size(1000, 'MB', 'GB', si_units=True)\nprint(size_in_gb)  # Output: 1.0\n```\n\n### Getting the Full Name of a Unit\n\nTo get the full name of a unit from its abbreviation, use the `get_name_from_code` function.\n\n```python\n# IEC unit name example\nunit_name = fsc.get_name_from_code('KiB')\nprint(unit_name)  # Output: Kibibyte\n\n# SI unit name example\nunit_name = fsc.get_name_from_code('KB', si_units=True)\nprint(unit_name)  # Output: Kilobyte\n```\n\n## Functions\n\n##### `convert_size(size: float, start_unit: str, end_unit: str, si_units: bool = False) -\u003e float`\n\nConvert a size between units, either IEC or SI.\n\n- `size` (float): The original size.\n- `start_unit` (str): The starting unit abbreviation.\n- `end_unit` (str): The ending unit abbreviation.\n- `si_units` (bool): If True, use SI units; otherwise, use IEC units.\n- Returns (float): The converted size.\n- Raises `ValueError`: If the unit abbreviations are not valid.\n\n##### `get_name_from_code(unit: str, si_units: bool = False) -\u003e str`\n\nGet the full name of a unit from its abbreviation.\n\n- `unit` (str): The unit abbreviation.\n- `si_units` (bool): If True, use SI units; otherwise, use IEC units.\n- Returns (str): The full name of the unit.\n- Raises `ValueError`: If the unit abbreviation is not valid.\n\n##### `get_name_from_code_iec(unit: str) -\u003e str`\n\nGet the full name of an IEC unit from its abbreviation.\n\n- `unit` (str): The IEC unit abbreviation.\n- Returns (str): The full name of the IEC unit.\n- Raises `ValueError`: If the unit abbreviation is not valid.\n\n##### `get_name_from_code_si(unit: str) -\u003e str`\n\nGet the full name of an SI unit from its abbreviation.\n\n- `unit` (str): The SI unit abbreviation.\n- Returns (str): The full name of the SI unit.\n- Raises `ValueError`: If the unit abbreviation is not valid.\n\n## Error Handling\n\nThe module raises `ValueError` exceptions for invalid unit abbreviations. Ensure that you handle these exceptions in your code:\n\n```python\ntry:\n    size_in_gib = fsc.convert_size(1024, 'MiB', 'GiB')\nexcept ValueError as e:\n    print(e)\n```\n\u003cbr /\u003e\n\u003cp align=\"right\"\u003e\u003ca href=\"https://wolfsoftware.com/\"\u003e\u003cimg src=\"https://img.shields.io/badge/Created%20by%20Wolf%20on%20behalf%20of%20Wolf%20Software-blue?style=for-the-badge\" /\u003e\u003c/a\u003e\u003c/p\u003e\n","funding_links":["https://github.com/sponsors/WolfSoftware","https://github.com/sponsors/TGWolf"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeveloperstoolbox%2Fconvert-size-package","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeveloperstoolbox%2Fconvert-size-package","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeveloperstoolbox%2Fconvert-size-package/lists"}