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.3] - 2024-08-23

Fixed

  • Fixed the Github Actions for python tests

[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.3.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

rel_path-1.0.3-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file rel_path-1.0.3.tar.gz.

File metadata

  • Download URL: rel_path-1.0.3.tar.gz
  • Upload date:
  • Size: 3.3 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.3.tar.gz
Algorithm Hash digest
SHA256 63232fc031c4f1d8d08a2c5534a71e4eae1a14312ac57e417b8ebcfbb3c10cf4
MD5 32ccfa9824eb3ca07c5838359128228d
BLAKE2b-256 bd8fa49c757ffb33602b5ff04c91dc795736f5f07c7e1cef5fba0ef107ccc517

See more details on using hashes here.

File details

Details for the file rel_path-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: rel_path-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.6 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1701d3ba2305ef26fd383127015cae9a67fbcd6237e30c08f0aaa6dc4c569797
MD5 120b0cf73c74670502c76a0911440f4f
BLAKE2b-256 812d614f762451dca0af631cc4f3e3dfde2466178c898c85b1fe095720dd801f

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