Skip to main content

Simplified file path management for Python developers

Project description

Way3: A Python Module for File Operations

Auto CI and Build Tools Auto Publish to PyPI and GitHub Release label label Release Version Visits License Stars Forks Downloads Contributors

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.

Installation

To install Way3, you can use pip:

pip install way3

or use poetry:

poetry add way3 

Usage

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

delete_file(file_name: str, file_path: Union[str, os.PathLike] = ".") -> tuple[bool, str]

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

get_current_dir(instance=file) -> str

Returns the current working directory.

Example:

import way3

result = way3.get_current_dir()
print(result)  # prints the current working directory

create_directory(directory_name: str, directory_path: Union[str, os.PathLike] = ".") -> str

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

rename_directory(original_name: str, new_name: str) -> str

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

delete_directory(directory_name: str, directory_path: Union[str, os.PathLike] = ".") -> str

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!

Testing

To run the tests, you can use the following command:

python3 -m unittest discover -s tests

License

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.

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

way3-1.0.4.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

way3-1.0.4-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file way3-1.0.4.tar.gz.

File metadata

  • Download URL: way3-1.0.4.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.6

File hashes

Hashes for way3-1.0.4.tar.gz
Algorithm Hash digest
SHA256 e0c3d11460c77b104d6195ae489e4943eaf3511d21934fc7ab0631ff6e6d3457
MD5 3d8ac7d922b2c7b7db47da4b49eab3c7
BLAKE2b-256 d989ba193f93bbdb1c78be54ad1b95049a9cbfd688b352680be19ea9de86c7e4

See more details on using hashes here.

File details

Details for the file way3-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: way3-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.6

File hashes

Hashes for way3-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 efc0e212e75d692a4a7cf2a734ce996f05adfa41a3bc2127b52811615cc8eb8d
MD5 aa342350e7da2493c5953463db30cc25
BLAKE2b-256 8683fc2eb727e05a58bc32afd6b7fab527ee43d4df42b32eb466bc3d66a89f1d

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