rawabs2rel
A python script that traverses a whole package turning local absolute imports into relative ones.
The difference between this and abs2rel is that this does NOT ask for consent.
It can reduce substantialy the time needed to convert local absolute imports from a Python package into local relative imports. Additionally, because the conversion is automated, it is less error-prone than having someone make the changes manually.
This command only recognizes local absolute imports which are in the from ... import ... format, where the from and import keywords are on the same line.
This script was originally tested on the nodezator app at commit be4c17f, managing to convert all 1685 existing absolute local imports across 270 python files into relative imports successfully, without needing any additional manual work.
If you want to try this yourself, just clone nodezator, checkout the mentioned commit and, inside the nodezator/nodezator folder, execute the rawabs2rel command. Then, go up one folder level and launch the app with python -m nodezator and you'll see that the local relative imports work properly, launching the app without problems.
Installation
pip install rawabs2rel
Usage
After installing, just go to your package top-level directory and execute the rawabs2rel command. Before actually changing the files, the script presents the number of imports and files that are about to be changed and asks the user to confirm in order to proceed. Remember to make a backup of your package before executing this script, just in case.
License
rawabs2rel is dedicated to the public domain with The Unlicense.
Metadata
Release files for rawabs2rel 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rawabs2rel-1.1.0.tar.gz | 4.5 kB | Without provenance | Details for rawabs2rel-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rawabs2rel-1.1.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for rawabs2rel-1.1.0-py2.py3-none-any.whl |
Total release size: 9.3 kB
Release files / rawabs2rel-1.1.0.tar.gz
| Download URL | rawabs2rel-1.1.0.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1b4781512a8a536eae186abb6e09e8d5ec489bdc9da9a199f4f3514a9faf4cf0
|
|
BLAKE2b-256 checksum How to use checksums |
0d79736daf5a2ac2295280979d3cb49ae3fd88b5d61db449c38ce6caa8e04de5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.12
|
Release files / rawabs2rel-1.1.0-py2.py3-none-any.whl
| Download URL | rawabs2rel-1.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
7e3ed7617ed68a1e9db501e8c4095521efced7315c3298b17f6a4dbf182e2488
|
|
BLAKE2b-256 checksum How to use checksums |
66c40f68826e6311cdc43ce8a5df8105f51457ba6b140f08eb65ad30dbf978ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.12
|
Security for rawabs2rel 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.