smartpathlibrary v1.0.1
Library for working with paths to files and folders.
⚠️ Disclaimer
By using this software, you agree to the full disclaimer terms.
Summary: Software provided "AS IS" without warranty. You assume all risks.
Full legal disclaimer: See DISCLAIMER.md
Help:
pip install smartpathlibrary
from smartpathlibrary.tools import PathManager, Dir, File, get_root_path, PathNormalizer, Counter, Folder
# ========== WORK WITH PATHS ==========
# Check existence
file = File("document.txt")
print(file.exists()) # False or True
folder = Folder("/home/user/docs")
print(folder.exists())
# Path normalization for different OS
normalized = PathNormalizer.normalize("/home/user/my file.txt")
# On Linux: '/home/user/my\ file.txt'
# On Windows: '/home/user/my file.txt'
# ========== DIRECTORY TRAVERSAL ==========
dir_obj = Dir("/home/user/project")
# Get all files recursively
for file in dir_obj.get_files(recursive=True):
print(file)
# Only files in root folder (no subfolders)
for file in dir_obj.get_files(recursive=False):
print(file)
# Get all subdirectories
for subdir in dir_obj.get_dirs(recursive=True):
print(subdir)
# Count
print(f"Files: {dir_obj.get_count_files(recursive=True)}")
print(f"Folders: {dir_obj.get_count_dirs(recursive=True)}")
# ========== PATH MANAGER ==========
pm = PathManager()
# Add single paths
pm.add_path("/home/user/project")
pm.add_path("/home/user/notes.txt")
# Add multiple paths
pm.add_paths([
"/home/user/docs",
"/home/user/readme.md"
])
# Get all files (recursive through all added folders)
all_files = list(pm.get_files(recursive=True))
print(f"Files found: {len(all_files)}")
# Get all subfolders
all_dirs = list(pm.get_dirs(recursive=True))
# Statistics
print(f"Total paths added: {pm.count}")
print(f"Total files (recursive): {pm.get_count_files()}")
print(f"Total folders: {pm.get_count_dirs()}")
# Remove paths
pm.remove_path("/home/user/notes.txt")
pm.remove_paths(["/home/user/docs"])
print(pm) # Paths(2)
# ========== GET ABSOLUTE PATH ==========
abs_path = get_root_path("data/config.json")
print(abs_path) # /full/path/to/script/folder/data/config.json
# ========== COUNT ITEMS IN ITERABLE ==========
counter = Counter()
items = [1, 2, 3, 4, 5]
print(counter.get_count(items)) # 5
License
Copyright (©) 2026, Alexander Suvorov
Metadata
Release files for smartpathlibrary 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| smartpathlibrary-1.0.1.tar.gz | 5.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| smartpathlibrary-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.4 kB
Release files / smartpathlibrary-1.0.1.tar.gz
| Download URL | smartpathlibrary-1.0.1.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6a562fac2c0bd199f2733eb6861956325e46c1b04a109ed7893d8efe1f160ee1
|
|
BLAKE2b-256 checksum How to use checksums |
ca971f63373627f45b8e4469fa8f7abccae2499c37b8474af06bdfae55138563
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / smartpathlibrary-1.0.1-py3-none-any.whl
| Download URL | smartpathlibrary-1.0.1-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
22b3c2f197575667aace948a02714ddf6b511f2a66bdec29ba3e7053d769397d
|
|
BLAKE2b-256 checksum How to use checksums |
45091637201e853a71b5f15546d1b99d750f6ec49c95113ff441af07cc288434
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|