Skip to content

Add method to convert bytes #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lguerard opened this issue Apr 22, 2025 · 0 comments
Closed

Add method to convert bytes #95

lguerard opened this issue Apr 22, 2025 · 0 comments
Assignees
Labels
enhancement New feature or request next-coding-session Look into during the next CS. next-release Issues blocking the next release
Milestone

Comments

@lguerard
Copy link
Contributor

lguerard commented Apr 22, 2025

@CellKai made this method already, it would be nice to integrate it to the libs.

def convert_bytes(size):
    """Convert size from bytes to a readable value

    Parameters
    ----------
    size : int
        Byte size

    Returns
    -------
    str
        Easy to read value with the correct unit
    """
    for x in ["bytes", "KB", "MB", "GB", "TB"]:
        if size < 1024.0:
            return "%3.1f %s" % (size, x)
        size /= 1024.0

    return size
@lguerard lguerard added enhancement New feature or request next-coding-session Look into during the next CS. next-release Issues blocking the next release labels Apr 22, 2025
@lguerard lguerard added this to the 1.6.0 milestone Apr 22, 2025
@lguerard lguerard self-assigned this Apr 22, 2025
@github-project-automation github-project-automation bot moved this to Done in imcflibs May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request next-coding-session Look into during the next CS. next-release Issues blocking the next release
Projects
Status: Done
Development

No branches or pull requests

2 participants