wolfsoftware.convert-size
Convert between various sizes.
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.7%) to scientific vocabulary
Keywords
Repository
Convert between various sizes.
Basic Info
Statistics
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 3
- Releases: 4
Topics
Metadata Files
README.md
Overview
The File Size Converter module provides functions for converting file sizes between different units in both IEC (binary) and SI (decimal) formats. It includes functionality for getting the full name of a unit from its abbreviation and converting sizes between units.
Features
- Convert sizes between different IEC units (e.g., Bytes to Kibibytes).
- Convert sizes between different SI units (e.g., Bytes to Kilobytes).
- Retrieve the full name of a unit from its abbreviation.
- Support for both IEC (binary) and SI (decimal) unit systems.
Installation
shell
pip install wolfsoftware.convert-size
Usage
Importing the Module
python
import wolfsoftware.convert_size as fsc
Converting Sizes
To 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.
```python
IEC conversion example
sizeingib = fsc.convertsize(1024, 'MiB', 'GiB') print(sizein_gib) # Output: 1.0
SI conversion example
sizeingb = fsc.convertsize(1000, 'MB', 'GB', siunits=True) print(sizeingb) # Output: 1.0 ```
Getting the Full Name of a Unit
To get the full name of a unit from its abbreviation, use the get_name_from_code function.
```python
IEC unit name example
unitname = fsc.getnamefromcode('KiB') print(unit_name) # Output: Kibibyte
SI unit name example
unitname = fsc.getnamefromcode('KB', siunits=True) print(unitname) # Output: Kilobyte ```
Functions
convert_size(size: float, start_unit: str, end_unit: str, si_units: bool = False) -> float
Convert a size between units, either IEC or SI.
size(float): The original size.start_unit(str): The starting unit abbreviation.end_unit(str): The ending unit abbreviation.si_units(bool): If True, use SI units; otherwise, use IEC units.- Returns (float): The converted size.
- Raises
ValueError: If the unit abbreviations are not valid.
get_name_from_code(unit: str, si_units: bool = False) -> str
Get the full name of a unit from its abbreviation.
unit(str): The unit abbreviation.si_units(bool): If True, use SI units; otherwise, use IEC units.- Returns (str): The full name of the unit.
- Raises
ValueError: If the unit abbreviation is not valid.
get_name_from_code_iec(unit: str) -> str
Get the full name of an IEC unit from its abbreviation.
unit(str): The IEC unit abbreviation.- Returns (str): The full name of the IEC unit.
- Raises
ValueError: If the unit abbreviation is not valid.
get_name_from_code_si(unit: str) -> str
Get the full name of an SI unit from its abbreviation.
unit(str): The SI unit abbreviation.- Returns (str): The full name of the SI unit.
- Raises
ValueError: If the unit abbreviation is not valid.
Error Handling
The module raises ValueError exceptions for invalid unit abbreviations. Ensure that you handle these exceptions in your code:
python
try:
size_in_gib = fsc.convert_size(1024, 'MiB', 'GiB')
except ValueError as e:
print(e)
Owner
- Name: Developers Toolbox
- Login: DevelopersToolbox
- Kind: organization
- Email: github@wolfsoftware.com
- Location: United Kingdom
- Website: https://wolfsoftware.com
- Twitter: wolfsoftware
- Repositories: 24
- Profile: https://github.com/DevelopersToolbox
A selection of tools to help developers. Created by Wolf Software.
Citation (CITATION.cff)
cff-version: 1.2.0
message: If you use this software, please cite it using these metadata.
title: Convert Sizes
abstract: Convert between various sizes.
type: software
version: 0.1.2
date-released: 2024-06-25
repository-code: https://github.com/DevelopersToolbox/convert-size
keywords:
- "Wolf Software"
- "Software"
license: MIT
authors:
- family-names: "Wolf"
orcid: "https://orcid.org/0009-0007-0983-2072"
GitHub Events
Total
- Delete event: 80
- Issue comment event: 162
- Push event: 127
- Pull request review event: 118
- Pull request event: 171
- Create event: 83
Last Year
- Delete event: 80
- Issue comment event: 162
- Push event: 127
- Pull request review event: 118
- Pull request event: 171
- Create event: 83
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 0
- Total pull requests: 125
- Average time to close issues: N/A
- Average time to close pull requests: 3 days
- Total issue authors: 0
- Total pull request authors: 2
- Average comments per issue: 0
- Average comments per pull request: 1.67
- Merged pull requests: 96
- Bot issues: 0
- Bot pull requests: 124
Past Year
- Issues: 0
- Pull requests: 92
- Average time to close issues: N/A
- Average time to close pull requests: 4 days
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 1.66
- Merged pull requests: 69
- Bot issues: 0
- Bot pull requests: 92
Top Authors
Issue Authors
- dependabot[bot] (1)
Pull Request Authors
- dependabot[bot] (190)
- TGWolf (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 11 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 3
- Total maintainers: 1
pypi.org: wolfsoftware.convert-size
Convert between various sizes.
- Homepage: https://github.com/DevelopersToolbox/convert-size-package
- Documentation: https://github.com/DevelopersToolbox/convert-size-package
- License: MIT
-
Latest release: 0.1.2
published over 1 year ago
Rankings
Maintainers (1)
Dependencies
- ActionsToolbox/get-language-versions-action 446919617fd774095b5dd3ed71c39dd3fd0d8f4f composite
- actions/checkout a5ac7e51b41094c92402da3b24376905380afc29 composite
- actions/setup-python 82c7e631bb3cdc910f68e0081d67478d79c6982d composite
- ActionsToolbox/get-language-versions-action 446919617fd774095b5dd3ed71c39dd3fd0d8f4f composite
- actions/checkout a5ac7e51b41094c92402da3b24376905380afc29 composite
- citation-file-format/cffconvert-github-action 4cf11baa70a673bfdf9dad0acc7ee33b3f4b6084 composite
- ruby/setup-ruby 0cde4689ba33c09f1b890c1725572ad96751a3fc composite
- Gamesight/slack-workflow-status 68bf00d0dbdbcb206c278399aa1ef6c14f74347a composite
- actions/checkout a5ac7e51b41094c92402da3b24376905380afc29 composite
- github/codeql-action/analyze a57c67b89589d2d13d5ac85a9fc4679c7539f94c composite
- github/codeql-action/autobuild a57c67b89589d2d13d5ac85a9fc4679c7539f94c composite
- github/codeql-action/init a57c67b89589d2d13d5ac85a9fc4679c7539f94c composite
- Gamesight/slack-workflow-status 68bf00d0dbdbcb206c278399aa1ef6c14f74347a composite
- Mattraks/delete-workflow-runs 39f0bbed25d76b34de5594dceab824811479e5de composite
- dependabot/fetch-metadata 5e5f99653a5b510e8555840e80cbf1514ad4af38 composite
- ActionsToolbox/get-language-versions-action 446919617fd774095b5dd3ed71c39dd3fd0d8f4f composite
- actions/checkout a5ac7e51b41094c92402da3b24376905380afc29 composite
- actions/setup-node 60edb5dd545a775178f52524783378180af0d1f8 composite
- ruby/setup-ruby 0cde4689ba33c09f1b890c1725572ad96751a3fc composite
- ActionsToolbox/get-language-versions-action 446919617fd774095b5dd3ed71c39dd3fd0d8f4f composite
- Bullrich/generate-release-changelog 6b60f004b4bf12ff271603dc32dbd261965ad2f2 composite
- actions/checkout a5ac7e51b41094c92402da3b24376905380afc29 composite
- actions/setup-python 82c7e631bb3cdc910f68e0081d67478d79c6982d composite
- softprops/action-gh-release 69320dbe05506a9a39fc8ae11030b214ec2d1f87 composite
- ActionsToolbox/get-language-versions-action 446919617fd774095b5dd3ed71c39dd3fd0d8f4f composite
- Bullrich/generate-release-changelog 6b60f004b4bf12ff271603dc32dbd261965ad2f2 composite
- actions/checkout a5ac7e51b41094c92402da3b24376905380afc29 composite
- actions/setup-python 82c7e631bb3cdc910f68e0081d67478d79c6982d composite
- softprops/action-gh-release 69320dbe05506a9a39fc8ae11030b214ec2d1f87 composite
- actions/first-interaction 34f15e814fe48ac9312ccf29db4e74fa767cbab7 composite
- Gamesight/slack-workflow-status 68bf00d0dbdbcb206c278399aa1ef6c14f74347a composite
- otto-de/purge-deprecated-workflow-runs 31a4e821d43e9a354cbd65845922c76e4b4b3633 composite
- ActionsToolbox/get-language-versions-action 446919617fd774095b5dd3ed71c39dd3fd0d8f4f composite
- actions/checkout a5ac7e51b41094c92402da3b24376905380afc29 composite
- actions/setup-go cdcb36043654635271a94b9a6d1392de5bb323a7 composite
- actions/setup-python 82c7e631bb3cdc910f68e0081d67478d79c6982d composite
- actions/checkout a5ac7e51b41094c92402da3b24376905380afc29 composite
- zgosalvez/github-actions-ensure-sha-pinned-actions 2f2ebc6d914ab515939dc13f570f91baeb2c194c composite
- Gamesight/slack-workflow-status 68bf00d0dbdbcb206c278399aa1ef6c14f74347a composite
- actions/stale 28ca1036281a5e5922ead5184a1bbf96e5fc984e composite
- pytest ==8.2.1
- setuptools ==70.0.0
- pytest ==8.2.2 development
- setuptools ==70.2.0 development