Skip to main content

safeIO

Safely make I/O operations to files in Python even from multiple threads... and more!

Table of Content

  1. safeIO
  2. Table of Content
  3. What is it?
  4. Installation
  5. Objects

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.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for safeIO 1.1.1
File Size Uploaded Provenance Actions
safeIO-1.1.1.tar.gz 7.6 kB Without provenance Details for safeIO-1.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for safeIO 1.1.1
File Interpreter ABI Platform Actions
safeIO-1.1.1-py3-none-any.whl Python 3 none any Details for safeIO-1.1.1-py3-none-any.whl

Total release size: 14.6 kB

Release files / safeIO-1.1.1.tar.gz

Download URL safeIO-1.1.1.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4fbe789250cf7edddddcd5d5f7ac696afc8815b0cabfa0e4d67e682b8d4c38cd
BLAKE2b-256 checksum
How to use checksums
d587fa97521767d6a3de79667055b774818968af551ee764268ed4d5a2dcfecf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.23.0 setuptools/49.6.0.post20201009 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1

Release files / safeIO-1.1.1-py3-none-any.whl

Download URL safeIO-1.1.1-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0a350e25500bfb997c58ddee88ff6ddac118457ffe19f47b022f2e7266cef813
BLAKE2b-256 checksum
How to use checksums
ba708e414eb58fa3b64d6450d51167da5ea628f01370d22c6aac080234789f38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.23.0 setuptools/49.6.0.post20201009 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1

Security for safeIO 1.1.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page