Catalog PyPI
PACKAGE EXPLORERView in registry

abs2rel

PyPI

A python script that traverses a whole package turning local absolute imports into relative ones.

codeimportspackageparsingpythonreplacementscriptsubstitutiontext
Versions collected1
Direct dependencies0From release 1.1.0
Last observed20 Oct, 17:36 UTC

README

Version 1.1.0 documentation

abs2rel

A python script that traverses a whole package turning local absolute imports into relative ones.

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 abs2rel 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 abs2rel

Usage

After installing, just go to your package top-level directory and execute the abs2rel 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

abs2rel is dedicated to the public domain with The Unlicense.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
1.1.06 Sept 20220

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
kennedyrichard/abs2rel

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 17:36 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:659971d386a6d0893f6330dfe722fe117a6e1fe1a325c4c54d27fad313b98152