Skip to main content

Library for working with paths to files and folders.

Project description

smartpathlibrary v1.0.1


Library for working with paths to files and folders.


PyPI Downloads GitHub release (latest by date) PyPI - Downloads GitHub top language PyPI GitHub PyPI - Format


⚠️ 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

BSD 3-Clause License

Copyright (©) 2026, Alexander Suvorov


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smartpathlibrary-1.0.1.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smartpathlibrary-1.0.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file smartpathlibrary-1.0.1.tar.gz.

File metadata

  • Download URL: smartpathlibrary-1.0.1.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for smartpathlibrary-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6a562fac2c0bd199f2733eb6861956325e46c1b04a109ed7893d8efe1f160ee1
MD5 a52b58bb08b0f279c5c833e89fe3c888
BLAKE2b-256 ca971f63373627f45b8e4469fa8f7abccae2499c37b8474af06bdfae55138563

See more details on using hashes here.

File details

Details for the file smartpathlibrary-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for smartpathlibrary-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 22b3c2f197575667aace948a02714ddf6b511f2a66bdec29ba3e7053d769397d
MD5 7a073b544eba344d801f50489cc31a31
BLAKE2b-256 45091637201e853a71b5f15546d1b99d750f6ec49c95113ff441af07cc288434

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page