pathflow-toolkit 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. pathflow_toolkit-0.1.0/.gitignore +158 -0
  2. pathflow_toolkit-0.1.0/CHANGELOG.md +56 -0
  3. pathflow_toolkit-0.1.0/LICENSE +21 -0
  4. pathflow_toolkit-0.1.0/PKG-INFO +219 -0
  5. pathflow_toolkit-0.1.0/README.md +181 -0
  6. pathflow_toolkit-0.1.0/pyproject.toml +102 -0
  7. pathflow_toolkit-0.1.0/src/path_file/__init__.py +223 -0
  8. pathflow_toolkit-0.1.0/src/path_file/__main__.py +6 -0
  9. pathflow_toolkit-0.1.0/src/path_file/_internal/__init__.py +87 -0
  10. pathflow_toolkit-0.1.0/src/path_file/_internal/_iterators.py +349 -0
  11. pathflow_toolkit-0.1.0/src/path_file/_internal/_log.py +153 -0
  12. pathflow_toolkit-0.1.0/src/path_file/_internal/_parsers.py +234 -0
  13. pathflow_toolkit-0.1.0/src/path_file/_internal/_safety.py +268 -0
  14. pathflow_toolkit-0.1.0/src/path_file/_version.py +1 -0
  15. pathflow_toolkit-0.1.0/src/path_file/actions.py +855 -0
  16. pathflow_toolkit-0.1.0/src/path_file/archive.py +447 -0
  17. pathflow_toolkit-0.1.0/src/path_file/chain.py +1028 -0
  18. pathflow_toolkit-0.1.0/src/path_file/cli.py +582 -0
  19. pathflow_toolkit-0.1.0/src/path_file/entries.py +459 -0
  20. pathflow_toolkit-0.1.0/src/path_file/exceptions.py +174 -0
  21. pathflow_toolkit-0.1.0/src/path_file/filters.py +654 -0
  22. pathflow_toolkit-0.1.0/src/path_file/hash.py +338 -0
  23. pathflow_toolkit-0.1.0/src/path_file/progress.py +321 -0
  24. pathflow_toolkit-0.1.0/src/path_file/py.typed +0 -0
  25. pathflow_toolkit-0.1.0/src/path_file/report.py +348 -0
  26. pathflow_toolkit-0.1.0/src/path_file/rules.py +481 -0
  27. pathflow_toolkit-0.1.0/src/path_file/search.py +472 -0
  28. pathflow_toolkit-0.1.0/src/path_file/sync.py +384 -0
  29. pathflow_toolkit-0.1.0/src/path_file/units.py +420 -0
  30. pathflow_toolkit-0.1.0/src/path_file/utils.py +509 -0
  31. pathflow_toolkit-0.1.0/src/path_file/watch.py +310 -0
  32. pathflow_toolkit-0.1.0/tests/conftest.py +170 -0
  33. pathflow_toolkit-0.1.0/tests/test_actions.py +315 -0
  34. pathflow_toolkit-0.1.0/tests/test_actions_deep.py +272 -0
  35. pathflow_toolkit-0.1.0/tests/test_archive.py +227 -0
  36. pathflow_toolkit-0.1.0/tests/test_archive_sync_entries.py +278 -0
  37. pathflow_toolkit-0.1.0/tests/test_chain.py +311 -0
  38. pathflow_toolkit-0.1.0/tests/test_chain_deep.py +459 -0
  39. pathflow_toolkit-0.1.0/tests/test_cli.py +353 -0
  40. pathflow_toolkit-0.1.0/tests/test_cli_inproc.py +451 -0
  41. pathflow_toolkit-0.1.0/tests/test_exceptions.py +190 -0
  42. pathflow_toolkit-0.1.0/tests/test_filters.py +206 -0
  43. pathflow_toolkit-0.1.0/tests/test_filters_deep.py +326 -0
  44. pathflow_toolkit-0.1.0/tests/test_final_gaps.py +367 -0
  45. pathflow_toolkit-0.1.0/tests/test_gap_fillers.py +352 -0
  46. pathflow_toolkit-0.1.0/tests/test_hash.py +173 -0
  47. pathflow_toolkit-0.1.0/tests/test_integration.py +372 -0
  48. pathflow_toolkit-0.1.0/tests/test_internals.py +264 -0
  49. pathflow_toolkit-0.1.0/tests/test_iterators_watch.py +253 -0
  50. pathflow_toolkit-0.1.0/tests/test_report_progress.py +187 -0
  51. pathflow_toolkit-0.1.0/tests/test_rules.py +227 -0
  52. pathflow_toolkit-0.1.0/tests/test_rules_deep.py +219 -0
  53. pathflow_toolkit-0.1.0/tests/test_search.py +188 -0
  54. pathflow_toolkit-0.1.0/tests/test_search_safety.py +238 -0
  55. pathflow_toolkit-0.1.0/tests/test_sync.py +301 -0
  56. pathflow_toolkit-0.1.0/tests/test_units_parsers_hash.py +341 -0
  57. pathflow_toolkit-0.1.0/tests/test_utils.py +418 -0
  58. pathflow_toolkit-0.1.0/tests/test_watch.py +191 -0
@@ -0,0 +1,158 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # Distribution / packaging
7
+ .Python
8
+ build/
9
+ develop-eggs/
10
+ dist/
11
+ downloads/
12
+ eggs/
13
+ .eggs/
14
+ lib/
15
+ lib64/
16
+ parts/
17
+ sdist/
18
+ var/
19
+ wheels/
20
+ pip-wheel-metadata/
21
+ share/
22
+ *.egg-info/
23
+ .installed.cfg
24
+ *.egg
25
+ MANIFEST
26
+
27
+ # PyInstaller
28
+ *.manifest
29
+ *.spec
30
+
31
+ # Installer logs
32
+ pip-log.txt
33
+ pip-delete-this-directory.txt
34
+
35
+ # Unit test / coverage reports
36
+ htmlcov/
37
+ .tox/
38
+ .nox/
39
+ .coverage
40
+ .coverage.*
41
+ .cache
42
+ nosetests.xml
43
+ pytestdebug.xml
44
+
45
+ # Translations
46
+ *.mo
47
+ *.pot
48
+
49
+ # Django stuff:
50
+ *.log
51
+ local_settings.py
52
+ db.sqlite3
53
+ db.sqlite3-journal
54
+
55
+ # Flask stuff:
56
+ instance/
57
+ .webassets-cache
58
+
59
+ # Scrapy stuff:
60
+ .scrapy
61
+
62
+ # Sphinx documentation
63
+ docs/_build/
64
+
65
+ # PyBuilder
66
+ .pybuilder/
67
+ target/
68
+
69
+ # Jupyter Notebook
70
+ .ipynb_checkpoints
71
+
72
+ # IPython
73
+ profile_default/
74
+ ipython_config.py
75
+
76
+ # pyenv
77
+ .python-version
78
+
79
+ # pipenv
80
+ Pipfile.lock
81
+
82
+ # poetry
83
+ poetry.lock
84
+
85
+ # pdm
86
+ .pdm.toml
87
+
88
+ # PEP 582
89
+ __pypackages__/
90
+
91
+ # Celery stuff
92
+ celerybeat-schedule
93
+ celerybeat.pid
94
+
95
+ # SageMath parsed files
96
+ *.sage.py
97
+
98
+ # Environments
99
+ .env
100
+ .venv
101
+ env/
102
+ venv/
103
+ ENV/
104
+ env.bak/
105
+ venv.bak/
106
+
107
+ # Spyder project settings
108
+ .spyderproject
109
+ .spyproject
110
+
111
+ # Rope project settings
112
+ .ropeproject
113
+
114
+ # mkdocs
115
+ /site
116
+
117
+ # mypy
118
+ .mypy_cache/
119
+ .dmypy.json
120
+ dmypy.json
121
+
122
+ # Pyre type checker
123
+ .pyre/
124
+
125
+ # pytype static type analyzer
126
+ .pytype/
127
+
128
+ # Cython debug symbols
129
+ cython_debug/
130
+
131
+ # IDE
132
+ .idea/
133
+ .vscode/
134
+ *.swp
135
+ *.swo
136
+ *~
137
+
138
+ # OS
139
+ .DS_Store
140
+ Thumbs.db
141
+
142
+ # Project specific
143
+ *.log
144
+ *.tmp
145
+ *.bak
146
+ .coverage.*
147
+ .pytest_cache/
148
+ htmlcov/
149
+ dist/
150
+ build/
151
+ *.egg-info/
152
+ .ruff_cache/
153
+ .acl-diagnose/
154
+ # Local dev reports
155
+ .collect.txt
156
+ .cov_report.txt
157
+ .final_run.txt
158
+ *.zip
@@ -0,0 +1,56 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2026-11-22
9
+
10
+ ### Added
11
+ - Initial release of path_file
12
+ - **FileChain**: Immutable, lazy, chainable file collection
13
+ - **40+ Filters**: files, dirs, extensions, size, time, name, path, visibility, permissions, content, duplicates
14
+ - **20+ Actions**: copy, move, delete, trash, rename, archive, compress, extract, chmod, touch, read/write, hash
15
+ - **Execution Modifiers**: dry-run, parallel, progress, verbose, error handling
16
+ - **Materialization**: count, first, last, to_list, to_paths, to_dict, to_json, to_csv, to_table, report, preview
17
+ - **Entry Class**: Rich metadata with lazy properties (size, dates, hash, content)
18
+ - **Report Class**: Aggregate statistics with table, JSON, CSV output
19
+ - **Units**: parse_size, human_size, parse_duration, human_ago, parse_datetime, human_duration
20
+ - **Rules Engine**: Declarative TOML-based automation rules
21
+ - **Watcher**: Polling-based folder monitoring with callbacks
22
+ - **Syncer**: Hash-based directory synchronization with conflict resolution
23
+ - **Hash Utilities**: SHA-256, MD5, duplicate detection, verification
24
+ - **Archive Utilities**: ZIP, TAR, TAR.GZ, TAR.BZ2, TAR.XZ, GZ, BZ2, XZ
25
+ - **Search**: Content search with text and regex
26
+ - **CLI**: Full command-line interface with 12 commands
27
+ - **Utilities**: 30+ helper functions for common file operations
28
+ - **Zero Dependencies**: Only Python standard library
29
+ - **Full Type Hints**: Strict mypy compliance
30
+ - **Comprehensive Tests**: 26 test files, 875 tests, 85% line coverage (verified)
31
+ - **Release-Gated Quality**: ruff check + ruff format --check + mypy strict + pytest --cov-fail-under=85 + twine check, all passing
32
+ - **Documentation**: API reference, quickstart, recipes, rules, CLI guide
33
+
34
+ ### Security
35
+ - Path traversal protection in archive extraction
36
+ - Dry-run by default for destructive operations
37
+ - Explicit confirmation required for delete/trash
38
+ - Safe path validation utilities
39
+
40
+ ### Performance
41
+ - os.scandir-based iteration (not os.walk)
42
+ - Parallel execution with ThreadPoolExecutor
43
+ - Streaming hash computation for large files
44
+ - Cached regex compilation
45
+ - Efficient size/time filtering (cutoff computed once)
46
+
47
+ ## [Unreleased]
48
+
49
+ ### Planned for v0.2.0
50
+ - Async/await support
51
+ - More archive formats (RAR, 7Z)
52
+ - EXIF/metadata support for photos
53
+ - Faster duplicate detection (xxhash)
54
+ - Configuration file (path_file.toml)
55
+ - Plugin system
56
+ - Web UI for rules management
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 Largo-m
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,219 @@
1
+ Metadata-Version: 2.5
2
+ Name: pathflow-toolkit
3
+ Version: 0.1.0
4
+ Summary: The elegant file automation library for Python
5
+ Project-URL: Homepage, https://github.com/Largo-m/path_file
6
+ Project-URL: Documentation, https://github.com/Largo-m/path_file#readme
7
+ Project-URL: Repository, https://github.com/Largo-m/path_file
8
+ Project-URL: Issues, https://github.com/Largo-m/path_file/issues
9
+ Project-URL: Changelog, https://github.com/Largo-m/path_file/blob/main/CHANGELOG.md
10
+ Author-email: Largo-m <Largo-m@users.noreply.github.com>
11
+ License: MIT
12
+ License-File: LICENSE
13
+ Keywords: automation,chainable,files,filters,pathlib,shutil,sync
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Topic :: System :: Filesystems
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.10
26
+ Provides-Extra: dev
27
+ Requires-Dist: black>=24.0; extra == 'dev'
28
+ Requires-Dist: build>=1.2; extra == 'dev'
29
+ Requires-Dist: mypy>=1.10; extra == 'dev'
30
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
31
+ Requires-Dist: pytest-xdist>=3.5; extra == 'dev'
32
+ Requires-Dist: pytest>=8.0; extra == 'dev'
33
+ Requires-Dist: ruff>=0.5; extra == 'dev'
34
+ Requires-Dist: twine>=5.0; extra == 'dev'
35
+ Provides-Extra: trash
36
+ Requires-Dist: send2trash>=1.5; extra == 'trash'
37
+ Description-Content-Type: text/markdown
38
+
39
+ # PathFile
40
+
41
+ > The elegant file automation library for Python.
42
+
43
+ [![PyPI](https://img.shields.io/pypi/v/path-file)](https://pypi.org/project/path-file/)
44
+ [![Python Versions](https://img.shields.io/pypi/pyversions/path-file)](https://pypi.org/project/path-file/)
45
+ [![License](https://img.shields.io/pypi/l/path-file)](LICENSE)
46
+ [![CI](https://github.com/Largo-m/path-file/workflows/CI/badge.svg)](https://github.com/Largo-m/path-file/actions)
47
+ [![Coverage](https://codecov.io/gh/Largo-m/path_file/branch/main/graph/badge.svg)](https://codecov.io/gh/Largo-m/path_file)
48
+
49
+ ---
50
+
51
+ ## Why PathFile?
52
+
53
+ Python's `pathlib` is great for single-file operations but painful for bulk operations, filtering, searching, and reporting. `shutil` has inconsistent APIs. Users end up writing 50-line scripts for tasks that should be 1 line.
54
+
55
+ **PathFile bridges this gap** with a chainable, declarative, dry-run-safe API.
56
+
57
+ ```python
58
+ # Before: 30 lines of pathlib + shutil + os.walk
59
+ # After: 1 line with path_file
60
+ import path_file as pf
61
+
62
+ pf.find("~/Downloads").files().with_extension(".jpg").larger_than("2MB").older_than(
63
+ "30 days"
64
+ ).move_to("~/Pictures/OldLarge").execute()
65
+ ```
66
+
67
+ ## Features
68
+
69
+ - 🔗 **Chainable API** - Fluent interface for complex operations
70
+ - 🛡️ **Dry-run by default** - Safety first for destructive operations
71
+ - 📦 **Zero dependencies** - Only Python standard library
72
+ - 🎯 **40+ filters** - Size, time, name, path, content, duplicates, permissions
73
+ - ⚡ **19 registered actions** - Copy, move, delete, trash, archive, extract, compress, hash, rename, touch, chmod, read/write, symlink, and more
74
+ - 📊 **Rich reporting** - Tables, JSON, CSV, summary statistics
75
+ - 🔄 **Parallel execution** - Multi-threaded with progress bars
76
+ - 📝 **Declarative rules** - TOML-based automation rules
77
+ - 👀 **Folder watching** - Polling-based file monitoring
78
+ - 🔁 **Directory sync** - Hash-based bidirectional synchronization
79
+ - 🖥️ **Full CLI** - 12 commands for terminal use
80
+ - 🏷️ **Full type hints** - Strict mypy compliance, IDE autocomplete
81
+
82
+ ## Installation
83
+
84
+ ```bash
85
+ pip install path-file
86
+ ```
87
+
88
+ Requires **Python 3.10+**
89
+
90
+ ## Quick Start
91
+
92
+ ```python
93
+ import path_file as pf
94
+
95
+ # Find and report
96
+ report = pf.find("~/Documents").report()
97
+ print(report.to_table())
98
+
99
+ # Batch operations with safety (preview first)
100
+ result = pf.find("~/Downloads").files().older_than("30 days").delete(dry_run=True).execute()
101
+ print(result.summary())
102
+
103
+ # Actually delete (requires confirmation)
104
+ pf.find("~/Downloads") \
105
+ .files() \
106
+ .older_than("30 days") \
107
+ .delete(confirm=True) \
108
+ .execute()
109
+
110
+ # Organize photos by date
111
+ pf.find("~/Photos") \
112
+ .files() \
113
+ .with_extensions(".jpg", ".png", ".heic") \
114
+ .for_each(lambda e: e.path.rename(f"~/Photos/Organized/{e.modified:%Y/%m}/{e.name}"))
115
+
116
+ # Sync with verification
117
+ syncer = pf.sync("~/Documents", "/backup/Documents")
118
+ syncer.direction("source_to_dest").delete_extras(True).progress()
119
+ diff = syncer.compare()
120
+ syncer.execute()
121
+
122
+ # Declarative rules
123
+ rules = pf.Rules.from_file("cleanup.toml")
124
+ rules.apply(pf.find("~/Downloads").files())
125
+ ```
126
+
127
+ ## Documentation
128
+
129
+ - [Publishing / PyPI release checklist](PUBLISHING.md)
130
+
131
+ - [Quick Start](docs/quickstart.md)
132
+ - [API Reference](docs/api.md)
133
+ - [Recipes](docs/recipes.md)
134
+ - [Rules Engine](docs/rules.md)
135
+ - [CLI Reference](docs/cli.md)
136
+
137
+ ## CLI Usage
138
+
139
+ ```bash
140
+ # Find files
141
+ path-file find ~/Downloads --ext .jpg --larger 2MB
142
+
143
+ # Generate report
144
+ path-file report ~/Documents --json
145
+
146
+ # Copy with progress
147
+ path-file copy ~/Photos /backup/Photos --ext .jpg --parallel 4
148
+
149
+ # Safe delete (requires --confirm)
150
+ path-file delete ~/Temp --ext .tmp --confirm
151
+
152
+ # Sync directories
153
+ path-file sync ~/Documents /backup/Documents --delete-extras --dry-run
154
+
155
+ # Find duplicates
156
+ path-file duplicates ~/Photos
157
+
158
+ # Archive
159
+ path-file archive ~/Projects -o backup.zip
160
+
161
+ # Watch folder
162
+ path-file watch ~/Downloads --filter "*.pdf" --on-new "notify.sh {}"
163
+
164
+ # Apply rules
165
+ path-file rules ~/Downloads -f cleanup.toml --apply
166
+ ```
167
+
168
+ ## Comparison
169
+
170
+ | Feature | pathlib | shutil | path_file |
171
+ |---------|---------|--------|----------|
172
+ | Chainable API | ❌ | ❌ | ✅ |
173
+ | Bulk filtering | Manual | Limited | ✅ 40+ filters |
174
+ | Dry-run safety | Manual | ❌ | ✅ Default |
175
+ | Progress bars | ❌ | ❌ | ✅ Built-in |
176
+ | Parallel execution | Manual | ❌ | ✅ Built-in |
177
+ | Content search | Manual | ❌ | ✅ Text & regex |
178
+ | Duplicate detection | Manual | ❌ | ✅ By hash/name |
179
+ | Declarative rules | ❌ | ❌ | ✅ TOML |
180
+ | Folder watching | ❌ | ❌ | ✅ Polling |
181
+ | Directory sync | ❌ | Manual | ✅ Hash-based |
182
+ | CLI | ❌ | ❌ | ✅ 12 commands |
183
+ | Zero dependencies | ✅ | ✅ | ✅ |
184
+ | Type hints | ✅ | Partial | ✅ Strict |
185
+
186
+ ## Examples
187
+
188
+ See [examples/](examples/) for 10 real-world scripts:
189
+
190
+ 1. `01_clean_downloads.py` - Clean old downloads
191
+ 2. `02_organize_photos.py` - Organize photos by date
192
+ 3. `03_backup_documents.py` - Backup with hash verification
193
+ 4. `04_find_duplicates.py` - Find and report duplicates
194
+ 5. `05_watch_and_sort.py` - Auto-sort downloads
195
+ 6. `06_sync_folders.py` - Bidirectional sync
196
+ 7. `07_rules_declarative.py` - Rules-based cleanup
197
+ 8. `08_compress_old_files.py` - Compress old files
198
+ 9. `09_rename_batch.py` - Batch rename photos
199
+ 10. `10_report_audit.py` - Generate audit reports
200
+
201
+ ## Contributing
202
+
203
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.
204
+
205
+ ## License
206
+
207
+ MIT License - see [LICENSE](LICENSE) for details.
208
+
209
+ ## Security
210
+
211
+ See [SECURITY.md](SECURITY.md) for security policy and vulnerability reporting.
212
+
213
+ ## Changelog
214
+
215
+ See [CHANGELOG.md](CHANGELOG.md) for release history.
216
+
217
+ ---
218
+
219
+ Made with ❤️ by [Largo-m](https://github.com/Largo-m)
@@ -0,0 +1,181 @@
1
+ # PathFile
2
+
3
+ > The elegant file automation library for Python.
4
+
5
+ [![PyPI](https://img.shields.io/pypi/v/path-file)](https://pypi.org/project/path-file/)
6
+ [![Python Versions](https://img.shields.io/pypi/pyversions/path-file)](https://pypi.org/project/path-file/)
7
+ [![License](https://img.shields.io/pypi/l/path-file)](LICENSE)
8
+ [![CI](https://github.com/Largo-m/path-file/workflows/CI/badge.svg)](https://github.com/Largo-m/path-file/actions)
9
+ [![Coverage](https://codecov.io/gh/Largo-m/path_file/branch/main/graph/badge.svg)](https://codecov.io/gh/Largo-m/path_file)
10
+
11
+ ---
12
+
13
+ ## Why PathFile?
14
+
15
+ Python's `pathlib` is great for single-file operations but painful for bulk operations, filtering, searching, and reporting. `shutil` has inconsistent APIs. Users end up writing 50-line scripts for tasks that should be 1 line.
16
+
17
+ **PathFile bridges this gap** with a chainable, declarative, dry-run-safe API.
18
+
19
+ ```python
20
+ # Before: 30 lines of pathlib + shutil + os.walk
21
+ # After: 1 line with path_file
22
+ import path_file as pf
23
+
24
+ pf.find("~/Downloads").files().with_extension(".jpg").larger_than("2MB").older_than(
25
+ "30 days"
26
+ ).move_to("~/Pictures/OldLarge").execute()
27
+ ```
28
+
29
+ ## Features
30
+
31
+ - 🔗 **Chainable API** - Fluent interface for complex operations
32
+ - 🛡️ **Dry-run by default** - Safety first for destructive operations
33
+ - 📦 **Zero dependencies** - Only Python standard library
34
+ - 🎯 **40+ filters** - Size, time, name, path, content, duplicates, permissions
35
+ - ⚡ **19 registered actions** - Copy, move, delete, trash, archive, extract, compress, hash, rename, touch, chmod, read/write, symlink, and more
36
+ - 📊 **Rich reporting** - Tables, JSON, CSV, summary statistics
37
+ - 🔄 **Parallel execution** - Multi-threaded with progress bars
38
+ - 📝 **Declarative rules** - TOML-based automation rules
39
+ - 👀 **Folder watching** - Polling-based file monitoring
40
+ - 🔁 **Directory sync** - Hash-based bidirectional synchronization
41
+ - 🖥️ **Full CLI** - 12 commands for terminal use
42
+ - 🏷️ **Full type hints** - Strict mypy compliance, IDE autocomplete
43
+
44
+ ## Installation
45
+
46
+ ```bash
47
+ pip install path-file
48
+ ```
49
+
50
+ Requires **Python 3.10+**
51
+
52
+ ## Quick Start
53
+
54
+ ```python
55
+ import path_file as pf
56
+
57
+ # Find and report
58
+ report = pf.find("~/Documents").report()
59
+ print(report.to_table())
60
+
61
+ # Batch operations with safety (preview first)
62
+ result = pf.find("~/Downloads").files().older_than("30 days").delete(dry_run=True).execute()
63
+ print(result.summary())
64
+
65
+ # Actually delete (requires confirmation)
66
+ pf.find("~/Downloads") \
67
+ .files() \
68
+ .older_than("30 days") \
69
+ .delete(confirm=True) \
70
+ .execute()
71
+
72
+ # Organize photos by date
73
+ pf.find("~/Photos") \
74
+ .files() \
75
+ .with_extensions(".jpg", ".png", ".heic") \
76
+ .for_each(lambda e: e.path.rename(f"~/Photos/Organized/{e.modified:%Y/%m}/{e.name}"))
77
+
78
+ # Sync with verification
79
+ syncer = pf.sync("~/Documents", "/backup/Documents")
80
+ syncer.direction("source_to_dest").delete_extras(True).progress()
81
+ diff = syncer.compare()
82
+ syncer.execute()
83
+
84
+ # Declarative rules
85
+ rules = pf.Rules.from_file("cleanup.toml")
86
+ rules.apply(pf.find("~/Downloads").files())
87
+ ```
88
+
89
+ ## Documentation
90
+
91
+ - [Publishing / PyPI release checklist](PUBLISHING.md)
92
+
93
+ - [Quick Start](docs/quickstart.md)
94
+ - [API Reference](docs/api.md)
95
+ - [Recipes](docs/recipes.md)
96
+ - [Rules Engine](docs/rules.md)
97
+ - [CLI Reference](docs/cli.md)
98
+
99
+ ## CLI Usage
100
+
101
+ ```bash
102
+ # Find files
103
+ path-file find ~/Downloads --ext .jpg --larger 2MB
104
+
105
+ # Generate report
106
+ path-file report ~/Documents --json
107
+
108
+ # Copy with progress
109
+ path-file copy ~/Photos /backup/Photos --ext .jpg --parallel 4
110
+
111
+ # Safe delete (requires --confirm)
112
+ path-file delete ~/Temp --ext .tmp --confirm
113
+
114
+ # Sync directories
115
+ path-file sync ~/Documents /backup/Documents --delete-extras --dry-run
116
+
117
+ # Find duplicates
118
+ path-file duplicates ~/Photos
119
+
120
+ # Archive
121
+ path-file archive ~/Projects -o backup.zip
122
+
123
+ # Watch folder
124
+ path-file watch ~/Downloads --filter "*.pdf" --on-new "notify.sh {}"
125
+
126
+ # Apply rules
127
+ path-file rules ~/Downloads -f cleanup.toml --apply
128
+ ```
129
+
130
+ ## Comparison
131
+
132
+ | Feature | pathlib | shutil | path_file |
133
+ |---------|---------|--------|----------|
134
+ | Chainable API | ❌ | ❌ | ✅ |
135
+ | Bulk filtering | Manual | Limited | ✅ 40+ filters |
136
+ | Dry-run safety | Manual | ❌ | ✅ Default |
137
+ | Progress bars | ❌ | ❌ | ✅ Built-in |
138
+ | Parallel execution | Manual | ❌ | ✅ Built-in |
139
+ | Content search | Manual | ❌ | ✅ Text & regex |
140
+ | Duplicate detection | Manual | ❌ | ✅ By hash/name |
141
+ | Declarative rules | ❌ | ❌ | ✅ TOML |
142
+ | Folder watching | ❌ | ❌ | ✅ Polling |
143
+ | Directory sync | ❌ | Manual | ✅ Hash-based |
144
+ | CLI | ❌ | ❌ | ✅ 12 commands |
145
+ | Zero dependencies | ✅ | ✅ | ✅ |
146
+ | Type hints | ✅ | Partial | ✅ Strict |
147
+
148
+ ## Examples
149
+
150
+ See [examples/](examples/) for 10 real-world scripts:
151
+
152
+ 1. `01_clean_downloads.py` - Clean old downloads
153
+ 2. `02_organize_photos.py` - Organize photos by date
154
+ 3. `03_backup_documents.py` - Backup with hash verification
155
+ 4. `04_find_duplicates.py` - Find and report duplicates
156
+ 5. `05_watch_and_sort.py` - Auto-sort downloads
157
+ 6. `06_sync_folders.py` - Bidirectional sync
158
+ 7. `07_rules_declarative.py` - Rules-based cleanup
159
+ 8. `08_compress_old_files.py` - Compress old files
160
+ 9. `09_rename_batch.py` - Batch rename photos
161
+ 10. `10_report_audit.py` - Generate audit reports
162
+
163
+ ## Contributing
164
+
165
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.
166
+
167
+ ## License
168
+
169
+ MIT License - see [LICENSE](LICENSE) for details.
170
+
171
+ ## Security
172
+
173
+ See [SECURITY.md](SECURITY.md) for security policy and vulnerability reporting.
174
+
175
+ ## Changelog
176
+
177
+ See [CHANGELOG.md](CHANGELOG.md) for release history.
178
+
179
+ ---
180
+
181
+ Made with ❤️ by [Largo-m](https://github.com/Largo-m)