Get relative path.
Project description
relpath - relative path module
This module addresses a limitation of the pathlib.Path
class. When using Path
, if the relative path is not a subdirectory of the base path, it raises a ValueError
. However, with this module, that weakness is eliminated.
Installation
pip install rel-path
Example for error:
from pathlib import Path
base="/home"
rel="/"
# Error when using Path
Path(rel).relative_to(base)
Exception has occurred: ValueError
'/' does not start with '/home'
Example using relpath module:
from relpath import relative_path
base="/home"
rel="/"
print(relative_path(base, rel))
../
Configure PyPi API Token
Poetry is used to manage the package. How to publish
To configure the PyPi API token, use the following command once:
# Run once to set the PyPi API token
set +o history
poetry config pypi-token.pypi '<your-pypi-token>'
set -o history
# Build the package
poetry build
# Publish the package
poetry publish
Support
If you encounter any issues with the relpath module, please report them on GitHub. I will respond as soon as possible. Contributions to the code are always welcome, and I appreciate ideas for new modules or improvements to existing ones.
Change Log
[1.0.2] - 2024-08-23
Added
- Added support for poetry
- Added Change Log to README.md
Removed
- Support for Python 3.6, 3.7, and 3.7
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
Built Distribution
File details
Details for the file rel_path-1.0.2.tar.gz
.
File metadata
- Download URL: rel_path-1.0.2.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.14 Linux/5.15.0-118-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbeb22e163e955af8c5028b6d98f5de228111a6b8cf061babcb5b2c3659cb035 |
|
MD5 | 9e67ca8910246678fef9c8552c39691d |
|
BLAKE2b-256 | 644914b54cff04b2b6e559f4f5368c39a4a43791fe2ada0a355b3bdf6c9c73fc |
File details
Details for the file rel_path-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: rel_path-1.0.2-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.14 Linux/5.15.0-118-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d825329d3493a476565fb652d3828100bd7fe1e17d7a9968ed28aa24ddde731 |
|
MD5 | 09da7fb6ef6e2c1d27847566a7895b6f |
|
BLAKE2b-256 | bbd87a75f2edbaa170c4772ff058ffca4007b1640c538e0d61936c13fb74aaba |