Install & Compatibility
Where this runs
tested against v0.3.14 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 240.6MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 16.0s · import 0.000s · 310MB
280MB installed
● package 280MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
File
✓ from pathmagic import File
✗ from pathmagic import File
Dir
✓ from pathmagic import Dir
This quickstart demonstrates the core functionality of `pathmagic.File` and `pathmagic.Dir` by creating a temporary directory and file, writing content, reading it back, and performing a rename operation via attribute modification. The `File` and `Dir` objects abstract away direct `os` or `pathlib` calls for these operations.
from pathmagic import File, Dir
import os
# Ensure a directory exists for demonstration
temp_dir_name = "pathmagic_demo_dir"
if not os.path.exists(temp_dir_name):
os.makedirs(temp_dir_name)
print(f"Working in directory: {temp_dir_name}")
# 1. Create a File object and write content
my_file_path = os.path.join(temp_dir_name, "my_document.txt")
my_file = File(my_file_path)
my_file.content = "Hello, pathmagic world!\nThis is a test."
print(f"Created file at: {my_file.path} and wrote content.")
# 2. Read content from the File object
read_content = my_file.content
print(f"Read content: \"{read_content.strip()}\"")
# 3. Modify a file attribute, triggering a filesystem operation (e.g., rename)
old_path = my_file.path
my_file.name = "renamed_document.txt" # This automatically renames the file on disk
print(f"File renamed from '{old_path}' to '{my_file.path}'")
# 4. Demonstrate a Dir object
my_dir = Dir(temp_dir_name)
print(f"Directory object created for: {my_dir.path}")
# Clean up
os.remove(my_file.path)
os.rmdir(temp_dir_name)
print("Cleaned up demo files and directory.")
Debug
Known issues
breakingThe `pathmagic` library is currently under active development, and its API is subject to significant changes that may introduce breaking changes in future versions. Code written with the current API may require adjustments.fixMonitor GitHub releases and the PyPI project page for API change announcements. Consider pinning specific minor versions if stability is critical.
affects: All versions prior to a stable 1.0 release (currently 0.x.x)
gotchaThe documentation for `pathmagic` may fall out of sync with updates due to the rapid development pace. Users might encounter undocumented features or outdated examples.fixRefer directly to the source code on GitHub for the most up-to-date understanding of the API and behavior if documentation appears to be insufficient or outdated.
affects: All versions prior to a stable 1.0 release (currently 0.x.x)
gotchaThis `pathmagic` library (for ORM-like filesystem objects) is frequently confused with the `python-magic` library (a Python interface to the `libmagic` file type identification library). Ensure you are installing and importing the correct package for your intended use case.fixDouble-check `pip install` commands and `import` statements to ensure they reference `pathmagic` if you intend to use the ORM-style path objects, not `python-magic`.
affects: All versions
Upgrade
Version history
0.3.14latest on PyPI · released Feb 1, 2021
Audit
Dependencies
No dependency data recorded yet.