Automatically translates .ini/.cfg files into TOML
Project description
ini2toml
Automatically translates .ini/.cfg files into TOML
Description
The original purpose of this project is to help migrating setup.cfg files to PEP 621, but by extension it can also be used to convert any compatible .ini/.cfg file to TOML.
Please notice, the provided .ini/.cfg files should follow the same syntax supported by Python’s ConfigParser library (here referred to as INI syntax) and more specifically abide by ConfigUpdater restrictions (e.g., no interpolation or repeated fields).
Usage
ini2toml comes in two flavours: “lite” and “full”. The “lite” flavour will create a TOML document that does not contain any of the comments from the original .ini/.cfg file. On the other hand, the “full” flavour will make an extra effort to translate these comments into a TOML-equivalent (please notice sometimes this translation is not perfect, so it is always good to check the TOML document afterwards).
To get started, you need to install the package, which can be easily done using pipx:
$ pipx install 'ini2toml[lite]'
# OR
$ pipx install 'ini2toml[full]'
Now you can use ini2toml as a command line:
# in you terminal
$ ini2toml --help
$ ini2toml path/to/ini/or/cfg/file
You can also use ini2toml in your Python scripts or projects:
# in your python code
from ini2toml.api import Translator
profile_name = "setup.cfg"
toml_str = Translator().translate(original_contents_str, profile_name)
To do so, don’t forget to add it to your virtual environment or specify it as a project dependency.
More details about ini2toml and its Python API can be found in our docs.
Making Changes & Contributing
This project uses pre-commit, please make sure to install it before making any changes:
pip install pre-commit cd ini2toml pre-commit install
It is a good idea to update the hooks to the latest version:
pre-commit autoupdate
Don’t forget to tell your contributors to also install and use pre-commit.
Note
This project has been set up using PyScaffold 4.1rc1. For details and usage information on PyScaffold see https://pyscaffold.org/.
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 ini2toml-0.0.1.tar.gz
.
File metadata
- Download URL: ini2toml-0.0.1.tar.gz
- Upload date:
- Size: 78.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6cbd4edce39df3f1554a51e22c2a1c50a8fc843553c416d3629871ecc8fe339 |
|
MD5 | 78d562635c459e22c34aceae2fd716d2 |
|
BLAKE2b-256 | 9988c00942fa9da2b495a0096b61ec27712cdd156a860816f42c6efd16225b9f |
File details
Details for the file ini2toml-0.0.1-py2.py3-none-any.whl
.
File metadata
- Download URL: ini2toml-0.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 41.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 379410087b016275a8207bb773d4a5b3a35b1fe98826cb404fe8b4d09a4a4682 |
|
MD5 | 5135d41d86bf94709458b8e45293604c |
|
BLAKE2b-256 | 2f2c10cf1898b81945b5b601bfad7552e2b1ab0174cea9b90d6c2c6a89f576b1 |