safeIO
Safely make I/O operations to files in Python even from multiple threads... and more!
Table of Content
What is it?
It's a module which lets you manage your files (most of the time, Input/Output operations) without worrying about accessing the file from two simultaneously.
Some functions may help you managing your files more easily as they are intuitive and things like substractions (TextFile object - TextFile Object returns the Cosine Similarity of the two files), equality (Object == Object), iteration (for line in TextFile object), the rename/move/delete methods are made easier!.
Installation
From PIP
pip install safeIO --upgrade
Objects
TextFile()
A Text File object
isfile
isfile(callback=None)
Wether the file exists on the disk or not
delete
delete(callback=None)
Deletes the file
rename
rename(newName,overwrite=False,callback=None)
Renames the file and returns its new path
move
move(newPath,overwrite=False,callback=None)
Moves the file and returns its new path
name
name(callback=None)
Returns the file name
fileno
fileno(callback=None)
Returns the file descriptor (int) used by Python to request I/O operations from the operating system.
read
read(position=0,callback=None)
Reads the entire file and returns its content
write
write(data,position=0,callback=None)
Writes (or overwrites) to the file and returns the number of characters written
append
append(data,callback=None)
Appends to the file and returns the number of characters written
readline
readline(position=0,callback=None)
Returns the line of the current position (from the position to the linebreak)
readlines
readlines(position=0,callback=None)
Reads the whole file and returns the lines (separated by a line break)
writelines
writelines(data,position=0,callback=None)
Writes (or overwrites) the given list of lines to the file
appendlines
appendlines(data,callback=None)
Appends the given list of lines to the file
detach
detach(mode="r",callback=None)
Returns the opened IO (TextIOWrapper)
Warning: Make sure to close the file correctly after using the file with detach
BinaryFile()
A Binary File object
isfile
isfile(callback=None)
Wether the file exists on the disk or not
delete
delete(callback=None)
Deletes the file
rename
rename(newName,overwrite=False,callback=None)
Renames the file and returns its new path
move
move(newPath,overwrite=False,callback=None)
Moves the file and returns its new path
name
name(callback=None)
Returns the file name
fileno
fileno(callback=None)
Returns the file descriptor (int) used by Python to request I/O operations from the operating system.
read
read(position=0,callback=None)
Reads the entire file and returns its content
write
write(data,position=0,callback=None)
Writes (or overwrites) to the file and returns the number of bytes written
append
append(data,callback=None)
Appends to the file and returns the number of bytes written
readline
readline(position=0,callback=None)
Returns the line of the current position (from the position to the linebreak)
readlines
readlines(position=0,callback=None)
Reads the whole file and returns the lines (separated by a line break)
writelines
writelines(data,position=0,callback=None)
Writes (or overwrites) the given list of lines to the file
appendlines
appendlines(data,callback=None)
Appends the given list of lines to the file
detach
detach(mode="rb",callback=None)
Returns the opened IO (TextIOWrapper)
Tips: Make sure to include the "b" access mode in the mode\n
Warning: Make sure to close the file correctly after using the file with detach
JSONFile()
A JSON File object
isfile
isfile(callback=None)
Wether the file exists on the disk or not
delete
delete(callback=None)
Deletes the file
rename
rename(newName,overwrite=False,callback=None)
Renames the file and returns its new path
move
move(newPath,overwrite=False,callback=None)
Moves the file and returns its new path
name
name(callback=None)
Returns the file name
fileno
fileno(callback=None)
Returns the file descriptor (int) used by Python to request I/O operations from the operating system.
read
read(position=0,callback=None)
Reads the entire file and returns its content
write
write(data,position=0,callback=None)
Writes (or overwrites) to the file and returns the number of characters written
append
append(data,callback=None)
Appends to the file and returns the number of characters written
detach
detach(mode="r",callback=None)
Returns the opened IO (TextIOWrapper)
Warning: Make sure to close the file correctly after using the file with detach
Markdown File | 325 lines
Metadata
Release files for safeIO 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| safeIO-1.0.tar.gz | 7.6 kB | Without provenance | Details for safeIO-1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| safeIO-1.0-py3-none-any.whl | Python 3 | none | any | Details for safeIO-1.0-py3-none-any.whl |
Total release size: 14.6 kB
Release files / safeIO-1.0.tar.gz
| Download URL | safeIO-1.0.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ff6247e13b7a154650875f19ae340fd68502c62f4700ce6fd50e0a6d65ee213
|
|
BLAKE2b-256 checksum How to use checksums |
869e407f754bbf60e06c511274a92636acd564b4bfa78cb2a0f3cf19b6703a9a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.8.0 tqdm/4.46.0 CPython/3.8.1
|
Release files / safeIO-1.0-py3-none-any.whl
| Download URL | safeIO-1.0-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a09296c724e76cd6d92dd6c4cc9af130d24fcdcf23839801e210068b87337ebf
|
|
BLAKE2b-256 checksum How to use checksums |
a401d8426fd9bcdf2b6568be257c30d06f54059fb7cf4f63d41e688e01f05185
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.8.0 tqdm/4.46.0 CPython/3.8.1
|
Security for safeIO 1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.