Skip to main content

get human-readable size of files

Project description

naturalsize

A Python toolkit for getting human-readable size of file and more

History

Originally designed only to return the human-readable size of a file,
naturalsize has developed itself to a Python toolkit with many useful functions.

Installation

Using pip

You can install naturalsize via pip using

  • in a commandline:

  • py -m pip install naturalsize
    

  • in a python script:

  • import os
    os.system('py -m pip install naturalsize')
    

    Usage

    naturalsize has many functions:

  • about() returns information about your release
  • nsize returns the human-readable filesize:
    naturalsize.nsize(556677)
    

    returns the size of a 556677 B large file.
    The args are:
    size for the files size in B
    comma for the rounding of the size (default: 2)
    base2 uses 1024 instead of 1000 as the base for the size (default: True)
    names as a list of names you give to file size units (default: ["B", "KB", "MB", "GB", ...])

  • randprinter prints random signs the following:
    naturalsize.randprinter(2000)
    

    This prints 2000 random signs.
    Args are:
    numb for the number of signs (default: 1000)
    signs as the list signs are chosen from (default: ["a", "b", "c", ...])

  • randprinter_ returns a callable randprinter object with the given specifications
  • special_starter waits for a given time and returns whether the user pressed Ctrl+c in this time:
    naturalsize.special_starter(100000000)
    

    passes 100 000 000 times and returns then False if the user hasn't interrupted the process.
    True is returned if the user interrupted.
    Args are:
    numbThe number the program passes before returning False (default: 150000000)

  • isInt returns whether a given object is an integer or a float, if this is accepted via the acceptFloat arg
  • listToInt sums up all integer or float, if this is accepted via the acceptFloat arg, and returns this
    Note that the acceptFloat arg is False by default.
  • reverse inverses the given boolean
  • replStr replaces a part of a string the following:
    naturalsize.replStr(1, "adc", "b")
    

    returns 'abc' as it replaces the value at index of a string with another string.
    The args are:
    index for the index the replacement is to be at (default: 0)
    strObj as the string replaced in (default: 'a')
    setIn as the string set in the other string (default: 'b')

  • replStrPassage replaces a passage of a string using the above function the following:
    naturalsize.replStrPassage(1, 2, "adec", "b")
    

    returns 'abc' as it replaces the values from indexstart to indexend of a string with another string.
    The index arg is split up into indexstart and indexend args
    for the begin and the end of the to-be-replaced passage (default: 0/1).

    More coming soon...

  • Project details


    Download files

    Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

    Source Distribution

    naturalsize-1.0.17.tar.gz (4.7 kB view details)

    Uploaded Source

    Built Distribution

    If you're not sure about the file name format, learn more about wheel file names.

    naturalsize-1.0.17-py3-none-any.whl (5.1 kB view details)

    Uploaded Python 3

    File details

    Details for the file naturalsize-1.0.17.tar.gz.

    File metadata

    • Download URL: naturalsize-1.0.17.tar.gz
    • Upload date:
    • Size: 4.7 kB
    • Tags: Source
    • Uploaded using Trusted Publishing? No
    • Uploaded via: twine/4.0.0 CPython/3.11.0

    File hashes

    Hashes for naturalsize-1.0.17.tar.gz
    Algorithm Hash digest
    SHA256 bd893192bd4e4c3167a4f000fb4f5c02ce154e7a5a84a040f58a80058f9139e2
    MD5 453ad61bd737a710817d9d50a57f75ea
    BLAKE2b-256 8ded0e99d73d3b3c60b3d77698621025ca38cce98df150d6ff18c1cb227afe4d

    See more details on using hashes here.

    File details

    Details for the file naturalsize-1.0.17-py3-none-any.whl.

    File metadata

    • Download URL: naturalsize-1.0.17-py3-none-any.whl
    • Upload date:
    • Size: 5.1 kB
    • Tags: Python 3
    • Uploaded using Trusted Publishing? No
    • Uploaded via: twine/4.0.0 CPython/3.11.0

    File hashes

    Hashes for naturalsize-1.0.17-py3-none-any.whl
    Algorithm Hash digest
    SHA256 5b2e21fd83eb5941dfda0d08c9bc429c8827d9c5dcfef3b0774d17580aa0c8b1
    MD5 aa36d093d60649417e5c7a449e4e8394
    BLAKE2b-256 a3fc5f4c9cb8f5a3dc57fca0b3caa9f8a2fd75166b48902091d31f4cd4da7a5f

    See more details on using hashes here.

    Supported by

    AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page