Automatically conversion of .ini/.cfg files to TOML equivalents
Project description
ini2toml
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 tool:
# 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.
Note
This project was initially created in the context of PyScaffold, with the purpose of helping migrating existing projects to PEP 621-style configuration when it is made available on setuptools. 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.8.tar.gz
.
File metadata
- Download URL: ini2toml-0.8.tar.gz
- Upload date:
- Size: 97.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a502b35e514b49531f408e93966f1d41d40b2003e59590f7430850af60b752d |
|
MD5 | a4d4e92f2c22ffa49dcdd3fac4980b79 |
|
BLAKE2b-256 | 32388d140491b16e305d4655bfc42b9bd79eb55136e8f7120d7aad2408840f64 |
File details
Details for the file ini2toml-0.8-py3-none-any.whl
.
File metadata
- Download URL: ini2toml-0.8-py3-none-any.whl
- Upload date:
- Size: 50.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af0282200340491b2b121656796c21adabd78dc61cff3f3c8585317fe70a3414 |
|
MD5 | c5012e7e153aa0da5e85ce20f5df283b |
|
BLAKE2b-256 | a9d12a2d0665dd729959a6e7e9ef7341187507ae34f745306a76f8260a6972b8 |