Advanced OOP file and directory management library with powerful search, logging and chainable file operations.
Project description
Tired of writing hundreds of lines with pathlib's verbose syntax? ๐คฏ
Meet NicePath.
A clean OOP path object with dozens of short, chainable methods and properties.
No try/except boilerplate. Just .read(), .write(), .move_to() โฆ and it works.
โจ Smart search ๐ณ Tree visualization ๐ Automatic logging of hundreds of files with a single method
Less code. More clarity.
๐ NicePy
Advanced OOP File & Directory Management Library for Python Built on top of pathlib with logging, search engine, tree view and smart utilities.
โจ Why NicePy?
NicePath is a powerful wrapper around Pythonโs built-in pathlib, designed to make file management:
โ Cleaner โ More readable โ More powerful โ Fully logged โ Searchable โ Tree-view ready
๐ฆ Installation
๐น Local Development Mode
pip install -e .
๐น Future PyPI Installation
pip install nicepython
๐ Quick Start
from nicepy import NicePath
Create path
p = NicePath("example.txt")
Write data
p.write("Hello NicePy!")
Read data
print(p.read())
Append
p.append("\nNew Line")
Show tree
root = NicePath(".") print(root.tree())
Search files
for f in root.search(suffix=".py"): print(f.path)
๐ณ Tree Visualization
root = NicePath("my_project") print(root.tree(ignore_hidden=False))
Example Output:
my_project โโโ main.py โโโ nicepy โ โโโ core.py โโโ README.md
๐ Advanced Search
root.search( name_contains="core", suffix=".py", recursive=True, ignore_hidden=True )
Supported Filters:
- name_contains
- suffix
- stem
- regex
- only_files
- only_dirs
- recursive
- ignore_hidden
If nothing is found โ returns [] (never raises error)
๐งพ logAll โ Full Project Logger
Generate:
- Full tree structure
- Content of matched files
- Save everything into a file
project = NicePath("my_project") output = NicePath("log.txt")
project.logAll( file_output=output, search_suffix=".py" )
Useful for:
- Project snapshot
- Debug logging
- Code export
- Archiving structure
๐ Available Methods
write(data) โ Write text to file read() โ Read file content append(data) โ Append to file delete() โ Remove file or directory copy_to(dest) โ Copy file/folder move_to(dest) โ Move file/folder search(...) โ Smart search engine tree(...) โ Visual tree display logAll(...) โ Full structured log export
Properties: exists is_file is_dir size created_time modified_time
โ NicePy vs pathlib
Feature | pathlib | NicePy
Basic read/write | Yes | Yes Append built-in | No | Yes Tree view | No | Yes Search engine | No | Yes Regex search | No | Yes Logging system | No | Yes Full project log export | No | Yes Unified OOP interface | Basic | Advanced Custom exceptions | No | Yes
โ ๏ธ Safety Limits in NicePath
NicePath library includes powerful methods like logAll, tree, and search that can traverse large directories or read/write many files.
To prevent accidental overloads, these methods have default safety limits:
- logAll: limits the maximum number of files and total size it processes.
- Default max_files=500
- Default max_total_size=10_000_000 bytes (10 MB)
- tree and search:
- Can ignore virtual environments and library folders (ignore_venv=True by default)
- Can limit recursion depth or number of entries if needed.
Behavior when limits are reached:
- The operation does not crash.
- Partial results are written to the output file.
- A warning message is logged with logger.warning stating that safety limits were reached.
Customizing Safety:
You can override safety defaults in method calls:
`python dir = NicePath("D:/Projects") output_file = dir / "log.txt"
dir.logAll( file_output=output_file, search_suffix=".py", max_files=1000, # increase limit max_total_size=50_000_000, # 50 MB ignore_venv=False # include virtual environments )
๐ Logging System
All critical operations are logged:
- Start
- Success
- Failure
- Error reason
Helps debugging and production stability.
๐งช Testing
pytest -v
๐ Project Structure
nicepy_python โโโ pycache โ โโโ init.pythonc โ โโโ main.cpython-314.pyc โโโ nicepy โ โโโ pycache โ โ โโโ init.pyc โ โ โโโ logger.cpython-314.pyc โ โโโ nicepath โ โ โโโ pycache โ โ โ โโโ init.pyc โ โ โ โโโ core.cpython-314.pyc โ โ โ โโโ exceptios.cpython-314.pyc โ โ โโโ init.py โ โ โโโ core.py โ โ โโโ exceptios.py โ โโโ init.py โ โโโ logger.py โโโ nicepy.egg-info โ โโโ dependency_links.txt โ โโโ PKG-INFO โ โโโ SOURCES.txt โ โโโ top_level.txt โโโ tests โ โโโ pycache โ โ โโโ test_nicepath.cpython-314-pytest-9.0.2.pyc โ โ โโโ test_nicepath.cpython-314.pyc โ โโโ newfolder โ โ โโโ ksc.txt โ โ โโโ tet.txt โ โ โโโ text.txt โ โโโ test_nicepath.py โโโ init.py โโโ main.py โโโ pyproject.toml โโโ README.md
๐ฎ Roadmap
[ ] PyPI release [ ] Async support [ ] Caching search engine [ ] Watchdog integration [ ] Colored tree output [ ] CLI interface
๐ค Author
Amin GitHub: https://github.com/amin13m
๐ License
MIT License
๐ Philosophy
Clean code. Predictable behavior. Zero surprise file handling.
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 nicepython-0.1.0.tar.gz.
File metadata
- Download URL: nicepython-0.1.0.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f8d13000e3f40dadaa521eb0b757ac62c4f75f3c1e85d9a5153e0e0d1b2c98e
|
|
| MD5 |
cec0889db63e91b79cce535be09826a1
|
|
| BLAKE2b-256 |
30d18508f10bd3bd8d387e50482435ec4c2dab07c0771a42aed0b57a10e616bc
|
File details
Details for the file nicepython-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nicepython-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65a41e402424b81994ac000748ab52d477d5adc074f128a8ee3d475baf3a8c3e
|
|
| MD5 |
ccfe05ef68d6a7186177ef9938744f56
|
|
| BLAKE2b-256 |
c6e27b1d5635ed0306b06fde19e0f95a23a01d19583b0c55f3bc16e762448d54
|