Delete files in a directory tree matching a glob pattern, dry run first.
Project description
1. Environment
- Python 3.14.6
- pip 26.1.2
2. Installation
$ pipx install spreen-clean
(pip install spreen-clean works too if you prefer managing the environment yourself.)
For development, install the dependencies via requirements.txt:
$ pip install -r requirements.txt
3. Execution
$ file-clean '*.log' --dirname ./tmp
Target dirname is /home/hayat01sh1da/workspace/tmp
========== [DRY RUN] Total File Count to Clean: 2 ==========
========== [DRY RUN] Start Cleaning *.log ==========
========== [DRY RUN] Cleaning ./tmp/app.log ==========
========== [DRY RUN] Cleaning ./tmp/jobs/worker.log ==========
========== [DRY RUN] Cleaned *.log ==========
========== [DRY RUN] Total Cleaned File Count: 2 ==========
The dry run above is the default. Once the list looks right, execute the deletion with --mode e (this cannot be undone):
$ file-clean '*.log' --dirname ./tmp --mode e
Target dirname is /home/hayat01sh1da/workspace/tmp
========== [EXECUTION] Total File Count to Clean: 2 ==========
========== [EXECUTION] Start Cleaning *.log ==========
========== [EXECUTION] Cleaning ./tmp/app.log ==========
========== [EXECUTION] Cleaning ./tmp/jobs/worker.log ==========
========== [EXECUTION] Cleaned *.log ==========
========== [EXECUTION] Total Cleaned File Count: 2 ==========
With no arguments, file-clean dry-runs every file under the current directory (PATTERN defaults to *, --dirname to .).
Two guardrails back the dry-run default: a dirname resolving to a filesystem root (/, C:\, ...) is refused before anything is scanned, and when the execution mode matches more than 100 files the CLI asks for an explicit y first — pass --yes to skip the prompt in scripts:
$ file-clean '*.log' --dirname ./tmp --mode e
About to delete 101 files (more than 100). Type `y` to proceed: n
Aborted the execution mode without deleting anything.
As a library:
from spreen_clean import Application
Application.run(dirname='./tmp', pattern='*.log') # dry run
Application.run(dirname='./tmp', pattern='*.log', mode='e') # execute
# The progress log goes to stdout by default; pass any text stream to capture it.
import io
stream = io.StringIO()
Application.run(dirname='./tmp', pattern='*.log', io=stream)
stream.getvalue() # => 'Target dirname is ...\n========== [DRY RUN] ...'
4. Unit Test
$ pytest
============================= test session starts ==============================
platform linux -- Python 3.14.6, pytest-9.1.1, pluggy-1.6.0
rootdir: spreen-clean/PyPI
configfile: pyproject.toml
collected 17 items
test/test_application.py ........ [ 47%]
test/test_cli.py ......... [100%]
============================== 17 passed in 0.42s ===============================
5. Static Code Analysis
$ flake8 .
$ autoflake8 --in-place --remove-duplicate-keys --remove-unused-variables --recursive .
$ autopep8 --in-place --aggressive --aggressive --recursive .
6. Type Checks
$ mypy .
Success: no issues found in 6 source files
7. Build
$ python -m build
$ pipx install ./dist/spreen_clean-0.1.0-py3-none-any.whl
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 spreen_clean-0.1.1.tar.gz.
File metadata
- Download URL: spreen_clean-0.1.1.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c71b677590265b7db7fbab1da063b162f09e7e5c286209e56a82132e07174e22
|
|
| MD5 |
bb89a1bd8b154f9bd96b80232a15bc78
|
|
| BLAKE2b-256 |
1e2e711038a1254dbf21073949336dc53c6107d37df39a9a9d7815355fe202e8
|
Provenance
The following attestation bundles were made for spreen_clean-0.1.1.tar.gz:
Publisher:
pypi--release.yml on hayat01sh1da/spreen-clean
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spreen_clean-0.1.1.tar.gz -
Subject digest:
c71b677590265b7db7fbab1da063b162f09e7e5c286209e56a82132e07174e22 - Sigstore transparency entry: 2205266576
- Sigstore integration time:
-
Permalink:
hayat01sh1da/spreen-clean@b8e85038bea82a17c3eea4a489062aac86190979 -
Branch / Tag:
refs/tags/python-v0.1.1 - Owner: https://github.com/hayat01sh1da
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi--release.yml@b8e85038bea82a17c3eea4a489062aac86190979 -
Trigger Event:
push
-
Statement type:
File details
Details for the file spreen_clean-0.1.1-py3-none-any.whl.
File metadata
- Download URL: spreen_clean-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
650379372a68ee0814fb3ae0d4a6cd62dc72250bd42308a80b4256458656f245
|
|
| MD5 |
2cc4c5c51d46111780fbcb4e8558c237
|
|
| BLAKE2b-256 |
c9f8ee814764df83c80ba181965d6657775150cebbf27b35f9e4c215b9697cc3
|
Provenance
The following attestation bundles were made for spreen_clean-0.1.1-py3-none-any.whl:
Publisher:
pypi--release.yml on hayat01sh1da/spreen-clean
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spreen_clean-0.1.1-py3-none-any.whl -
Subject digest:
650379372a68ee0814fb3ae0d4a6cd62dc72250bd42308a80b4256458656f245 - Sigstore transparency entry: 2205266590
- Sigstore integration time:
-
Permalink:
hayat01sh1da/spreen-clean@b8e85038bea82a17c3eea4a489062aac86190979 -
Branch / Tag:
refs/tags/python-v0.1.1 - Owner: https://github.com/hayat01sh1da
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi--release.yml@b8e85038bea82a17c3eea4a489062aac86190979 -
Trigger Event:
push
-
Statement type: