Skip to main content

A faster, more efficient Python file input and output framework

Project description


PyBetterFileIO

A faster, more efficient Python file input and output framework

Table of Contents

  1. About The Project
  2. Installation
  3. Usage
  4. Default Python vs. PyBetterFileIO

About The Project

PyBetterFileIO is the most intuitive, efficient, and accessible way to perform file input and output functions in python. Designed to improve the syntax of Python's included libraries, PyBetterFileIO is an effective tool. Create and edit files and folders, copy and move files and directories, and more. Treat your files and directories like objects in Python.

Installation

pip install PyBetterFileIO

Usage

from PyBetterFileIO import *

Functions and Implementation

File Commands

new_file = file("new_file.txt") # Instantiate a file object (required!)
new_file.make() # Make the file in the defined directory
new_file.create() # Create the file in the defined directory
new_file.write("Hello World!") # Clears and writes to file's content
new_file.append(" It's a beautiful day.") # Adds onto file's existing content
new_file.replace("Hello World!", "Goodbye World!") # Finds and replaces file's content
new_file.move_to("folder_or_path_to_move_to.optional") # Moves file to specified location
new_file.rename("folder_to_move_to/old_file.txt") # Rename the file
new_file.delete() # Delete the file
new_file.remove() # Remove the file
new_file.copy("test_folder/fun_file.txt") # Copy file to parameter's location
new_file.copy_and_rename("test_folder/fun_file.txt") # Copy file to parameter's location
new_file.copy_to("test_folder/fun_file.txt") # Copy file to parameter's location
new_file.read() # Returns file text content
new_file.print() # Prints file text content
new_file.exists() # Returns boolean if file exists
new_file.get_filename() # Returns file's path
new_file.get_default_file_object() # Returns a default file object allowing new_file to act as: with open(...) as new_file:
new_file.get_custom_file_object() # Returns a PyBetterFileIO file object from a default object where default is from: with open(...) as new_file

Folder Commands

new_folder = folder("new_folder") # Instantiate a folder object (required!)
new_folder.make() # Make the file in the defined directory
new_folder.create() # Create the file in the defined directory
new_folder.replace("not_needed_folder") # Replaces content of parameter's folder with object's content
new_folder.rename("folder_to_move_to/old_file.txt") # Rename the file
new_folder.delete() # Delete the file
new_folder.remove() # Remove the file
new_folder.create_file("name_of_file.txt") # Create a file inside folder
new_folder.make_file("name_of_file.txt") # Make a file inside folder
new_folder.copy_to("test_folder") # Copy folder to parameter's location
new_folder.copy_contents_to("test_folder") # Copy contents to parameter's location
new_folder.move_to("test_folder") # Moves to parameter's location without keeping original directory
new_folder.list() # Returns a list of all files in folder object
new_folder.read() # Returns file text content
new_folder.print() # Prints file text content
new_folder.exists() # Returns boolean if folder exists
new_folder.clear() # Clears folder content
new_folder.get_foldername() # Returns file's path

Static Method

Folder.clear_at("directory") # Clears specified directory

Default Python vs. PyBetterFileIO

Making a File

Default Python

with open("file.txt", 'w') as file:
  file.write()

PyBetterFileIO

file("file.txt").make()

Writing to a file

Default Python

with open("file.txt", "w") as file:
  file.write("Hello World!")

PyBetterFileIO

file("file.txt").write("Hello World!")

Replacing text in a file

Default Python

# Assume already existing file
with open('file.txt', 'r') as file:
  filedata = file.read()

filedata = filedata.replace('abcd', 'ram')

with open('file.txt', 'w') as file:
  file.write(filedata)

PyBetterFileIO

file("file.txt").replace("abcd", "ram")

Copy Contents of a Folder

Default Python

files = os.listdir("contents")
for file in files:
  shutil.copy(os.path.join("contents", file), os.path.join("other_content", "test_folder", file))

PyBetterFileIO

folder("contents").copy_contents_to("other_content/test_folder")

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

PyBetterFileIO-1.0.9.tar.gz (7.6 kB view details)

Uploaded Source

File details

Details for the file PyBetterFileIO-1.0.9.tar.gz.

File metadata

  • Download URL: PyBetterFileIO-1.0.9.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.7

File hashes

Hashes for PyBetterFileIO-1.0.9.tar.gz
Algorithm Hash digest
SHA256 f3fbce1859e707e723ffc3b0aa290e49aa3e93d12d2e9cb94790e531cbc321d3
MD5 796c2f68f1d546c89f494de1647746db
BLAKE2b-256 18396314251158d17ba1baab2a44390ecf143c53ca652cbaea636afd38aad72e

See more details on using hashes here.

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