Metadata-Version: 2.1
Name: abs2rel
Version: 1.1.0
Summary: A python script that traverses a whole package turning local absolute imports into relative ones.
Home-page: https://github.com/KennedyRichard/abs2rel
Author: Kennedy Richard
Author-email: kennedy@kennedyrichard.com
License: Unlicense
Project-URL: Source, https://github.com/KennedyRichard/abs2rel
Project-URL: Bug Tracker, https://github.com/KennedyRichard/abs2rel/issues
Keywords: parsing,imports,text,python,code,substitution,replacement,script,package
Classifier: License :: OSI Approved :: The Unlicense (Unlicense)
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing
Requires-Python: >=3.6
Description-Content-Type: text/markdown

# 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](https://github.com/IndiePython/nodezator) at commit [be4c17f](https://github.com/IndiePython/nodezator/commit/be4c17f4c9d09951b48345836fb24de70f5ee90f), 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

```bash
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](https://unlicense.org/).
