Skip to main content

Automatically conversion of .ini/.cfg files to TOML equivalents

Project description

Built Status ReadTheDocs Coveralls PyPI-Server Project generated with PyScaffold

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ini2toml-0.9.tar.gz (99.7 kB view details)

Uploaded Source

Built Distribution

ini2toml-0.9-py3-none-any.whl (51.2 kB view details)

Uploaded Python 3

File details

Details for the file ini2toml-0.9.tar.gz.

File metadata

  • Download URL: ini2toml-0.9.tar.gz
  • Upload date:
  • Size: 99.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for ini2toml-0.9.tar.gz
Algorithm Hash digest
SHA256 878f6ed0fd4725d17a077d98d3514e202472c4c5010014229f27c5df08efdf26
MD5 81241cfd7f8c80c78e5cee2e2f64d9f9
BLAKE2b-256 b54d8bde5ba86a360bb70649e9b8145e6d93595175a6a89eeba4d54ef9b483c8

See more details on using hashes here.

File details

Details for the file ini2toml-0.9-py3-none-any.whl.

File metadata

  • Download URL: ini2toml-0.9-py3-none-any.whl
  • Upload date:
  • Size: 51.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for ini2toml-0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 d299b5e9d3831363246d5f06932898e8b99fe12015a8768e5e288101e0e5904d
MD5 b3db5692652c84d4de12ac5879ecbf9c
BLAKE2b-256 37e36217a4e1df01e09f08da0e0485e2bd34fb97d3001c4a4796d674f9b16c69

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page