Yo Mama
Project description
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.
Project details
Release history Release notifications | RSS feed
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 rawabs2rel-1.1.0.tar.gz
.
File metadata
- Download URL: rawabs2rel-1.1.0.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b4781512a8a536eae186abb6e09e8d5ec489bdc9da9a199f4f3514a9faf4cf0 |
|
MD5 | 95bf0454d4a9eb12cb04515932dd67a7 |
|
BLAKE2b-256 | 0d79736daf5a2ac2295280979d3cb49ae3fd88b5d61db449c38ce6caa8e04de5 |
File details
Details for the file rawabs2rel-1.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: rawabs2rel-1.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e3ed7617ed68a1e9db501e8c4095521efced7315c3298b17f6a4dbf182e2488 |
|
MD5 | bb2506bd41d66be939a54e38a313e6eb |
|
BLAKE2b-256 | 66c40f68826e6311cdc43ce8a5df8105f51457ba6b140f08eb65ad30dbf978ce |