A simple file utility
Project description
file-util
file-util is a Python library that performs simple file operations, including:
- file creation
- file copying
- combining two files into a third
- file deletion
Installation
Use pip to install file-util
Unix
python3 -m venv venv
source venv/bin/activate
pip install .
Windows
python3 -m venv venv
.\venv\Scripts\activate
pip install .
Testing/Development
For running unit tests or active development, use the following installation command:
pip install --editable "./[dev]"
The package will be updated for each change you make, and install "dev" requirements like pytest.
Usage
usage: file-util [-h] {create,cp,cmb,rm} ...
A simple file utility
options:
-h, --help show this help message and exit
Subcommands:
Choose one of the file-util functions from the follow subcommands
{create,cp,cmb,rm}
Subcommand: create
usage: file-util create [-h] [-c] filepath [content ...]
Create a new file, either empty or with content
positional arguments:
filepath File path to create new file at, will ask for confirmation if file already exists at the path
content Optional: Content to write to new file
options:
-h, --help show this help message and exit
-c, --confirm Overwrite existing files without confirmation
Subcommand: cp
usage: file-util cp [-h] [-c] src_filepath dest_filepath
Copy existing file to another location
positional arguments:
src_filepath File path of source file to be copied
dest_filepath File path of destination to copy to, will ask for confirmation if file already exists at the path
options:
-h, --help show this help message and exit
-c, --confirm Overwrite existing file without confirmation
Subcommand: cmb
usage: file-util cmb [-h] [-c] first_filepath second_filepath dest_filepath
Combine two existing files into a new file
positional arguments:
first_filepath File path of first source file
second_filepath File path of second source file
dest_filepath File path of destination to write new file to, will ask for confirmation if file already exists
at the path
options:
-h, --help show this help message and exit
-c, --confirm Overwrite existing file without confirmation
Subcommand: rm
usage: file-util rm [-h] [-c] filepath
Delete a file
positional arguments:
filepath File path of file to delete, will ask for confirmation before deleting
options:
-h, --help show this help message and exit
-c, --confirm Delete file without confirmation
Running Unit Tests
Unit tests are implemented with Pytest. Use this command to install file-util for testing or development.
pytest tests/
Uploading
Based off https://packaging.python.org/en/latest/tutorials/packaging-projects/
TestPyPi
python3 -m pip install --upgrade pip build twine
python3 -m pip install . # to install file-util
python3 -m build
python3 -m twine upload --repository testpypi --config <path_to_.pypirc> dist/*
PyPi
python3 -m pip install --upgrade pip build twine
python3 -m pip install . # to install file-util
python3 -m build
python3 -m twine upload <path_to_.pypirc> dist/*
Updating this README
This README uses cog to insert the help text of file-util into the Usage section. After making updates to file-util's arguments or help text, install cog and update this documentation:
pip install cogapp
cog -r README.md
License
This project is licensed under the terms of the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file file_util_adriangassen-1.0.0.tar.gz.
File metadata
- Download URL: file_util_adriangassen-1.0.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e7f30bad60fb7054e3267da73affc11064b9b845aba9f34beac915a0ecb24d9
|
|
| MD5 |
52ffbfb3665c5abf5540d9bc4f3a25e6
|
|
| BLAKE2b-256 |
b4b9590a7914aebf4686e87af2da4a8d04dca595d672d6d581bb7dc9a5f7b21a
|
File details
Details for the file file_util_adriangassen-1.0.0-py3-none-any.whl.
File metadata
- Download URL: file_util_adriangassen-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cd64299c42da9ea67594e6410abaf88b989aeed6af8d9352d6ac29013f6dc4e
|
|
| MD5 |
edd8943130c6a767df2b5e9c744f620a
|
|
| BLAKE2b-256 |
c69761292f762241a6592ae8d25f846f4305995dc58b3574873a2821df856fc4
|