Skip to main content

Simple API for performing file and directory operations

Project description

File Operations

Simple python API for performing directory and file-based operations.

Installation

You can install the file_operations library with the following command:

pip install file_operations==1.0.5

Then import into your program as:

import file_operations

def main():
    data = "aabaaba"
    src_file = "hello.src"
    dest_file = "hello.dest"

    file_operations.write_file(src_file, data, mode='w')
    file_operations.copy_file(src_file, dest_file)

if __name__ == '__main__':
    main()

API Architecture

The following discusses the available methods in this library:

read_bytes(src_file, offset, limit)

copy_file(src_file, dest_file)
write_file(dest_file, data, mode ='w', overwrite = False)
move_file(src_file, dest_file)
remove_file(src_file)

create_dir(dest_dir)
copy_dir(src_dir, dest_dir, overwrite = False)
move_dir(src_dir, dest_dir)
remove_dir(dest_dir)

buffered_reader(file_name, buffer_size, mode ='rb'):
buffered_reader.has_next()
buffered_reader.read()
buffered_reader.close()

The _file methods require both src_file and dest_file to be formatted as path/file_name.extension. Note the buffered_reader is a class which is used for reading a large file in chunks, the size of each chunk is buffer_size. If an operation is successfully applied, then the function returns True and False otherwise.

For coding interview preparation, please visit [algorithmspath.com] (https://algorithmspath.com).

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

file_operations-1.0.5.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

file_operations-1.0.5-py3-none-any.whl (4.2 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