Skip to main content

Get relative path.

Project description

relpath - relative path module

Python package GitHub license Known Vulnerabilities

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

rel_path-1.0.2.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

rel_path-1.0.2-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

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

Hashes for rel_path-1.0.2.tar.gz
Algorithm Hash digest
SHA256 bbeb22e163e955af8c5028b6d98f5de228111a6b8cf061babcb5b2c3659cb035
MD5 9e67ca8910246678fef9c8552c39691d
BLAKE2b-256 644914b54cff04b2b6e559f4f5368c39a4a43791fe2ada0a355b3bdf6c9c73fc

See more details on using hashes here.

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

Hashes for rel_path-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3d825329d3493a476565fb652d3828100bd7fe1e17d7a9968ed28aa24ddde731
MD5 09da7fb6ef6e2c1d27847566a7895b6f
BLAKE2b-256 bbd87a75f2edbaa170c4772ff058ffca4007b1640c538e0d61936c13fb74aaba

See more details on using hashes here.

Supported by

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