pydtl-relativepath


Namepydtl-relativepath JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/python-dev-tools/pydtl-relativepath
Summarypython tool to solve many issues with relative paths and imports in your complex framework.
upload_time2024-06-10 22:22:46
maintainerNanthagopal-Eswaran
docs_urlNone
authorNanthagopal-Eswaran
requires_python<4.0.0,>=3.9
licenseMIT
keywords relative path absolute path python pydtl python-dev-tools poetry pytest
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pydtl-relativepath

pydtl-relativepath tool from pydtl community can be used to solve many issues that occurs with relative paths and imports from various modules in your complex framework.

[![Tests](https://github.com/python-dev-tools/pydtl-relativepath/actions/workflows/build_and_tests.yml/badge.svg)](https://github.com/python-dev-tools/pydtl-relativepath/actions/workflows/build_and_tests.yml)
[![codecov](https://codecov.io/gh/python-dev-tools/pydtl-relativepath/graph/badge.svg?token=WULZU647T4)](https://codecov.io/gh/python-dev-tools/pydtl-relativepath)
[![Linting](https://github.com/python-dev-tools/pydtl-relativepath/actions/workflows/lint.yml/badge.svg)](https://github.com/python-dev-tools/pydtl-relativepath/actions/workflows/lint.yml)
![Python Version](https://img.shields.io/badge/Python%20Versions-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue)
![OS Support](https://img.shields.io/badge/OS%20Support-Windows%20%7C%20Linux%20%7C%20MacOS-blue)

## 🔍 Features

- **Convert Relative Paths to Absolute**: Easily convert relative paths to absolute paths based on the current working directory or the current file's directory.
- **PathLib Compatibility**: Seamlessly works with PathLib, allowing for modern path manipulations.
- **Customizable Path Construction**: Adjust path construction through parameters like `parent_dir_jump` to navigate through directory structures.
- **Error Handling**: Provides clear error messages for invalid inputs, such as incorrect `relative_type` values or `parent_dir_jump` configurations.

## 🔧 Installation

To install `pydtl-relativepath`, run the following command in your terminal:

```bash
pip install pydtl-relativepath
```

## 💻 Usage Examples

### Convert Path Relative to Working Directory

To convert a path relative to the current working directory into an absolute path:

```python
from pydtl_relativepath import rel2abs, RelativePathType

path = rel2abs("README.md", relative_type=RelativePathType.RELATIVE_TO_WORKING_DIRECTORY)
print(path)  # Outputs the absolute path to README.md
```

### Convert Path Relative to Current File's Directory

To convert a path relative to the current file's directory:

```python
from pydtl_relativepath import rel2abs, RelativePathType

path = rel2abs("..", "README.md", relative_type=RelativePathType.RELATIVE_TO_CURRENT_FILE)
print(path)  # Outputs the absolute path to README.md located one directory up from the current file
```

### Using parent_dir_jump to Navigate Directories

To navigate up or down the directory structure while converting paths:

```python
from pydtl_relativepath import rel2abs, RelativePathType

# Navigate up one directory from the current file's location
path = rel2abs("README.md", relative_type=RelativePathType.RELATIVE_TO_CURRENT_FILE, parent_dir_jump=-1)
print(path)  # Outputs the absolute path to README.md located one directory up
```

### Handling Errors

The package is designed to raise informative errors for invalid inputs:

```python
from pydtl_relativepath import rel2abs, RelativePathType

try:
    path = rel2abs("README.md", relative_type="invalid_type")
except ValueError as e:
    print(e)  # Will print an error message regarding the invalid relative_type
```

## 🤝 Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues to improve the package or add new features.

See our [Contribution Guide](CONTRIBUTING.md) for more details.

## 📜 License

pydtl-relativepath is released under the MIT License. See the LICENSE file for more details.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/python-dev-tools/pydtl-relativepath",
    "name": "pydtl-relativepath",
    "maintainer": "Nanthagopal-Eswaran",
    "docs_url": null,
    "requires_python": "<4.0.0,>=3.9",
    "maintainer_email": "nanthagopaleswaran@gmail.com",
    "keywords": "relative path, absolute path, python, pydtl, python-dev-tools, poetry, pytest",
    "author": "Nanthagopal-Eswaran",
    "author_email": "nanthagopaleswaran@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/62/83/9f8ede8e43a5bea148889b9f215e1a66514251f342b972acbf3f7e380651/pydtl_relativepath-0.2.0.tar.gz",
    "platform": null,
    "description": "# pydtl-relativepath\n\npydtl-relativepath tool from pydtl community can be used to solve many issues that occurs with relative paths and imports from various modules in your complex framework.\n\n[![Tests](https://github.com/python-dev-tools/pydtl-relativepath/actions/workflows/build_and_tests.yml/badge.svg)](https://github.com/python-dev-tools/pydtl-relativepath/actions/workflows/build_and_tests.yml)\n[![codecov](https://codecov.io/gh/python-dev-tools/pydtl-relativepath/graph/badge.svg?token=WULZU647T4)](https://codecov.io/gh/python-dev-tools/pydtl-relativepath)\n[![Linting](https://github.com/python-dev-tools/pydtl-relativepath/actions/workflows/lint.yml/badge.svg)](https://github.com/python-dev-tools/pydtl-relativepath/actions/workflows/lint.yml)\n![Python Version](https://img.shields.io/badge/Python%20Versions-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue)\n![OS Support](https://img.shields.io/badge/OS%20Support-Windows%20%7C%20Linux%20%7C%20MacOS-blue)\n\n## \ud83d\udd0d Features\n\n- **Convert Relative Paths to Absolute**: Easily convert relative paths to absolute paths based on the current working directory or the current file's directory.\n- **PathLib Compatibility**: Seamlessly works with PathLib, allowing for modern path manipulations.\n- **Customizable Path Construction**: Adjust path construction through parameters like `parent_dir_jump` to navigate through directory structures.\n- **Error Handling**: Provides clear error messages for invalid inputs, such as incorrect `relative_type` values or `parent_dir_jump` configurations.\n\n## \ud83d\udd27 Installation\n\nTo install `pydtl-relativepath`, run the following command in your terminal:\n\n```bash\npip install pydtl-relativepath\n```\n\n## \ud83d\udcbb Usage Examples\n\n### Convert Path Relative to Working Directory\n\nTo convert a path relative to the current working directory into an absolute path:\n\n```python\nfrom pydtl_relativepath import rel2abs, RelativePathType\n\npath = rel2abs(\"README.md\", relative_type=RelativePathType.RELATIVE_TO_WORKING_DIRECTORY)\nprint(path)  # Outputs the absolute path to README.md\n```\n\n### Convert Path Relative to Current File's Directory\n\nTo convert a path relative to the current file's directory:\n\n```python\nfrom pydtl_relativepath import rel2abs, RelativePathType\n\npath = rel2abs(\"..\", \"README.md\", relative_type=RelativePathType.RELATIVE_TO_CURRENT_FILE)\nprint(path)  # Outputs the absolute path to README.md located one directory up from the current file\n```\n\n### Using parent_dir_jump to Navigate Directories\n\nTo navigate up or down the directory structure while converting paths:\n\n```python\nfrom pydtl_relativepath import rel2abs, RelativePathType\n\n# Navigate up one directory from the current file's location\npath = rel2abs(\"README.md\", relative_type=RelativePathType.RELATIVE_TO_CURRENT_FILE, parent_dir_jump=-1)\nprint(path)  # Outputs the absolute path to README.md located one directory up\n```\n\n### Handling Errors\n\nThe package is designed to raise informative errors for invalid inputs:\n\n```python\nfrom pydtl_relativepath import rel2abs, RelativePathType\n\ntry:\n    path = rel2abs(\"README.md\", relative_type=\"invalid_type\")\nexcept ValueError as e:\n    print(e)  # Will print an error message regarding the invalid relative_type\n```\n\n## \ud83e\udd1d Contributing\n\nContributions are welcome! Please feel free to submit pull requests or open issues to improve the package or add new features.\n\nSee our [Contribution Guide](CONTRIBUTING.md) for more details.\n\n## \ud83d\udcdc License\n\npydtl-relativepath is released under the MIT License. See the LICENSE file for more details.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "python tool to solve many issues with relative paths and imports in your complex framework.",
    "version": "0.2.0",
    "project_urls": {
        "Discussion": "https://github.com/python-dev-tools/pydtl-relativepath/discussions",
        "Homepage": "https://github.com/python-dev-tools/pydtl-relativepath",
        "Repository": "https://github.com/python-dev-tools/pydtl-relativepath",
        "Source": "https://github.com/python-dev-tools/pydtl-relativepath",
        "Tracker": "https://github.com/python-dev-tools/pydtl-relativepath/issues"
    },
    "split_keywords": [
        "relative path",
        " absolute path",
        " python",
        " pydtl",
        " python-dev-tools",
        " poetry",
        " pytest"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7fc255ae1ab1f40409ea3559c912bb685d6ae39470f083b580b6bfb2a993d746",
                "md5": "df08147add351ebf33bd9b052df74c39",
                "sha256": "a2b16372ae6b2e757eef4106b307c16f67509ae26573019b00663c53fe979f56"
            },
            "downloads": -1,
            "filename": "pydtl_relativepath-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "df08147add351ebf33bd9b052df74c39",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0.0,>=3.9",
            "size": 5104,
            "upload_time": "2024-06-10T22:22:45",
            "upload_time_iso_8601": "2024-06-10T22:22:45.310633Z",
            "url": "https://files.pythonhosted.org/packages/7f/c2/55ae1ab1f40409ea3559c912bb685d6ae39470f083b580b6bfb2a993d746/pydtl_relativepath-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "62839f8ede8e43a5bea148889b9f215e1a66514251f342b972acbf3f7e380651",
                "md5": "a8baeb07e1937a2be6104528753ae484",
                "sha256": "331aa62c5ae0feffdf696a8a0b777bd410bf48397c826e3b34a31bfedba209f2"
            },
            "downloads": -1,
            "filename": "pydtl_relativepath-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a8baeb07e1937a2be6104528753ae484",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0.0,>=3.9",
            "size": 4522,
            "upload_time": "2024-06-10T22:22:46",
            "upload_time_iso_8601": "2024-06-10T22:22:46.835139Z",
            "url": "https://files.pythonhosted.org/packages/62/83/9f8ede8e43a5bea148889b9f215e1a66514251f342b972acbf3f7e380651/pydtl_relativepath-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-10 22:22:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "python-dev-tools",
    "github_project": "pydtl-relativepath",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pydtl-relativepath"
}
        
Elapsed time: 0.44117s