NicePath Documentation
NicePath is an advanced OOP wrapper around pathlib with smart search, logging and safety systems.
Path Types
Absolute Path
NicePath("C:/Projects/file.txt")
Relative Path
NicePath("data/file.txt")
Caller Relative Path
NicePath("data/file.txt" , base_dir = __file__)
NicePath resolves relative paths based on the caller file location, not the execution directory.
File Operations
Write
NicePath("a.txt").write("Hello")
Read
NicePath("a.txt").read()
Append
NicePath("a.txt").append("More")
Move
NicePath("a.txt").move_to("b.txt")
Copy
NicePath("a.txt").copy_to("backup/a.txt")
Smart Search
dir = NicePath("project")
dir.search(
name_contains="test",
suffix=".py",
recursive=True,
ignore_venv=True
)
| Argument | Description |
|---|---|
| name_contains | Partial filename match |
| suffix | Extension filter |
| recursive | Include subfolders |
| ignore_hidden | Ignore hidden files |
| ignore_venv | Ignore virtual env |
Tree
NicePath("project").tree(
recursive=True,
ignore_hidden=True,
ignore_venv=True
)
Generates a graphical folder tree.
logAll
root = NicePath("project")
log = NicePath("log.txt")
root.logAll(
file_output=log,
search_suffix=".py",
ignore_venv=True
)
Safety System
- safety_max_files
- safety_max_size
- safety_max_depth
- safety_disable_limits
If safety limit is reached: • Process stops safely • Warning is logged • No crash occurs
NicePy Docs