Skip to main content

Easytexts: Simplified text management for quick projects

Project description

Easytexts: A Simple File Handler for Python

Install Easytexts using pip:

pip install easytext

Usage:

Import the easytexts module:

from Easytexts import *

Writing and Appending:

append(location_and_name, text, log=False, newline=True): Appends text to a file, optionally adding a newline and logging the action. Example:

append(“my_file.txt”, “This is a new line.”) # Optional: Log the action append(“my_file.txt”, “Another line!”, log=True)

rewrite(location_and_name, text, log=False): Overwrites the entire content of a file with new text, optionally logging the action. Example:

rewrite(“my_file.txt”, “This is the new content.n”)

create_if_doesnt_exist(location_and_name, text, log=False): Creates a new file and writes text to it, handling existing files gracefully, optionally logging the action. Example:

create_if_doesnt_exist(“new_file.txt”, “Hello, world!n”)

Reading:

read(location_and_name, log=False): Reads the entire content of a file and returns it as a string, optionally logging the action. Example:

content = read(“my_file.txt”) print(content)

Clearing and Checking:

clear(location_and_name, log=False): Empties the content of a file, optionally logging the action. Example:

clear(“my_file.txt”)

is_clear(location_and_name, log=False): Checks if a file is empty, returning True if empty, False otherwise, optionally logging the result. Example:

if is_clear(“my_file.txt”):

print(“The file is empty.”)

Deleting:

delete(location_and_name): Deletes a file. Example:

delete(“old_file.txt”)

Checking Existence:

does_exist(location_and_name): Checks if a file exists, returning True if exists, False otherwise. Example:

if does_exist(“my_file.txt”):

print(“The file exists.”)

Disclaimer

While Easytext handles common errors and is suitable for learning and small projects, it’s not intended for critical or demanding projects due to its limited scope and testing.

Additional Notes

The log parameter allows you to control if certain actions are logged for debugging or tracking purposes. The newline parameter in append allows you to control whether a newline character is added before the appended text.

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

Easytexts-0.4.0.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

Easytexts-0.4.0-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file Easytexts-0.4.0.tar.gz.

File metadata

  • Download URL: Easytexts-0.4.0.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for Easytexts-0.4.0.tar.gz
Algorithm Hash digest
SHA256 6c833bb0fb1dc21daecb88cfe31d3722024953cce7c5b1429be3c5ca0854e25f
MD5 af19f5e74c64d8798ea37c04a4335562
BLAKE2b-256 09426b1fa37639f232ad9e4f24a9a0a884a65f8f85630d43d3708b5d57189c4b

See more details on using hashes here.

File details

Details for the file Easytexts-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: Easytexts-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for Easytexts-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0cf7664e89e8a41e19ab36bf4e6c07f36eafdf64c123d0393aec8b4c6ae787f0
MD5 75dde92946e9da3c4d28622c0761b88a
BLAKE2b-256 7a367e0037b795231fe961352a7e4d0dbabe9bdf54906c48112768c94e1b0ec2

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