No project description provided
Project description
./
Dot Slash is a filepath helper that does one job; it resolves a filepath relative to the directory of the file where it is invoked. Which sounds more complicated than it is. In other words, if you find yourself thinking, "I need to access a file and I know its location relative to the code I'm writing now, but I don't really know/care where it is relative to the root of my filesystem, and I'd rather not worry about what the working directory is when I run this code" then you are in the right place.
Usage
from pathlib import Path
from dot_slash import dot_slash
contents = Path(dot_slash("my_sibling.json")).read_text()
print(contents)
A Few Examples
Given the following file layout, where you are invoking dot_slash() from invoker.py,
which (please note) is not in the working directory
/root/some/path/to/working_dir
│
├─ A
│ ├ invoker.py
│ └ sibling.txt
│
└─ B
└ cousin.json
these paths resolve as follows
# invoker.py
from dot_slash import dot_slash
dot_slash("..") # -> /root/some/path/to/working_dir/
dot_slash(".") # -> /root/some/path/to/working_dir/A/
dot_slash("sibling.txt") # -> /root/some/path/to/working_dir/A/sibling.txt
dot_slash("../B/cousin.json") # -> /root/some/path/to/working_dir/B/cousin.json
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 dot_slash-1.0.0.tar.gz.
File metadata
- Download URL: dot_slash-1.0.0.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/5.15.133.1-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
102d623f397490f984f2dc621ab93353f4a47adb67708f8ee39b15b7b2130e0c
|
|
| MD5 |
4481a2581e6769174f57231538b30246
|
|
| BLAKE2b-256 |
c358ad162bd215a314007ba318e0f3d0f5b60ecbde1d4cd1a0892d7d818ab5ba
|
File details
Details for the file dot_slash-1.0.0-py3-none-any.whl.
File metadata
- Download URL: dot_slash-1.0.0-py3-none-any.whl
- Upload date:
- Size: 2.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/5.15.133.1-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbe6fd33f928eaee11ce3f88ccb024f3cb2bfe85cd898d0bc319660f97189169
|
|
| MD5 |
84b01409fcbaaa305342e09bb59ff94c
|
|
| BLAKE2b-256 |
5b67baca6002ad0b12e31ef89d55e2d62d2db21b032568ee5cfffaf0ebdfc796
|