Skip to main content

Easytexts: Simplified text management for quick projects

Project description

EasyText: A Simple File Handler for Python

Install EasyText using pip:

pip install easytext

Usage:

Import the EasyText module:

from easytext 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.3.0.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

easytexts-0.3.0-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file easytexts-0.3.0.tar.gz.

File metadata

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

File hashes

Hashes for easytexts-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b672178bd79b1ae94235bd9c846579f6f543fdceb93e6a2710c92b5e6f9bba98
MD5 ff1325ad25048b4480e5b8bc0c7b0458
BLAKE2b-256 d40f3321995b3ab812b9c5048d85ef59ad7afa0f9380715e7237a051c00b02e4

See more details on using hashes here.

File details

Details for the file easytexts-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: easytexts-0.3.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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ace4b1503af9296f30454403e87ff92a5e56ed3e49093295e262464eb108108d
MD5 734f1ae792c54af1e36532ce7031a09d
BLAKE2b-256 07577448b14b3b38e215a15285692dfefb1f838a3168855d42924e96dc732aee

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