Skip to main content

An easy to use interface for basic file handling operations.

Project description

simple_file_handler

The FileHandler class provides an interface to perform most file operations easily and intuitively. All you need is the file path.

import simple_file_handler as sfh

# Use in a with statement to ensure the file is closed after use
with sfh.FileHandler('path/to/file.txt') as hdl:
    try:
        # Read the handled file's content
        data = hdl.read_file(mode='r')
        # Write to the handled file
        hdl.write_file(b'Hello World!', mode='ab')
        # Make a copy of the handled file
        copy_hdl = hdl.make_copy('path/to/directory', filename='file_copy')
        print(copy_hdl.file_path)
        # Delete the handled file
        hdl.delete_file()
    except sfh.FileError as exc:
        print(exc)

Installation

Do a pip install from the command line:

pip install simple-file-handler

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

simple_file_handler-0.0.1.tar.gz (22.1 kB view hashes)

Uploaded Source

Built Distribution

simple_file_handler-0.0.1-py3-none-any.whl (20.1 kB view hashes)

Uploaded Python 3

Supported by

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