Way3 is a Python module for performing file operations such as creating, appending to, and deleting files. It provides a convenient and easy-to-use interface for performing file operations.
To install Way3, you can use pip:
pip install way3
or use poetry:
poetry add way3
Here are the functions provided by Way3:
create_file(file_name: str, content: str, file_path: Union[str, os.PathLike] = ".", force_rewrite: bool = True) -> tuple[bool, str]
Creates a new file with the given file name and content. If the file already exists and force_rewrite
is set to True, the file will be overwritten.
Example:
import way3
result = way3.create_file("test.txt", "test")
print(result[1]) # prints the absolute path of the created file
add_to_file_end(file_name: str, content: str, file_path: Union[str, os.PathLike] = ".", create_if_not_exist: bool = True) -> tuple[bool, str]
Appends the given content to the end of the file with the given file name. If the file does not exist and create_if_not_exist
is set to True, a new file will be created.
Example:
import way3
result = way3.add_to_file_end("test.txt", "test")
print(result[1]) # prints the absolute path of the file
Deletes the file with the given file name.
Example:
import way3
result = way3.delete_file("test.txt")
print(result[1]) # prints the absolute path of the deleted file
Returns the current working directory.
Example:
import way3
result = way3.get_current_dir()
print(result) # prints the current working directory
Creates a new directory with the given name.
Example:
import way3
result = way3.create_directory("my_directory")
print(result) # prints the absolute path of the created directory
Renames a directory with a new name.
Example:
import way3
result = way3.rename_directory("old_directory", "new_directory")
print(result) # prints the absolute path of the renamed directory
Deletes a directory and all its contents.
Example:
import way3
result = way3.delete_directory("my_directory")
print(result) # prints the absolute path of the deleted directory
Let me know if you need any further modifications!
To run the tests, you can use the following command:
python3 -m unittest discover -s tests
Way3 is released under the MIT License. See LICENSE for details.
I hope you find Way3 useful! If you have any questions or feedback, please open an issue or pull request.