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
)
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:
numb
The 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
File details
Details for the file naturalsize-1.0.16.tar.gz
.
File metadata
- Download URL: naturalsize-1.0.16.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7390a773364edbb4ba39db8c1f17cb040fe16ed56301ee686e72053e20c01f74 |
|
MD5 | 348a43a3ba4fb06ab70f03cbc960ad66 |
|
BLAKE2b-256 | e9ee21b651ce82201f1ce3ec89f18309768d405e0a1c0c110511d11579619bf9 |
File details
Details for the file naturalsize-1.0.16-py3-none-any.whl
.
File metadata
- Download URL: naturalsize-1.0.16-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 882156fd616cccf14c63f338d7e469c4bcb8191fa72d95e51b47d17b906e7533 |
|
MD5 | 6b1da1c1343e330fd490d43075e4f0e3 |
|
BLAKE2b-256 | 8fb79fbbe63841566f71e435c4a2a42ca428621a56030c5e4f268bcc75cb2838 |