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
py -m pip install naturalsize
import os
os.system('py -m pip install naturalsize')
Usage
naturalsize has many functions:
about() returns information about your releasensize 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 specificationsspecial_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 arglistToInt sums up all integer or float, if this is accepted via the acceptFloat arg, and returns thisNote that the
acceptFloat arg is False by default.reverse inverses the given booleanreplStr 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd893192bd4e4c3167a4f000fb4f5c02ce154e7a5a84a040f58a80058f9139e2
|
|
| MD5 |
453ad61bd737a710817d9d50a57f75ea
|
|
| BLAKE2b-256 |
8ded0e99d73d3b3c60b3d77698621025ca38cce98df150d6ff18c1cb227afe4d
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b2e21fd83eb5941dfda0d08c9bc429c8827d9c5dcfef3b0774d17580aa0c8b1
|
|
| MD5 |
aa36d093d60649417e5c7a449e4e8394
|
|
| BLAKE2b-256 |
a3fc5f4c9cb8f5a3dc57fca0b3caa9f8a2fd75166b48902091d31f4cd4da7a5f
|