qtoml


Nameqtoml JSON
Version 0.3.1 PyPI version JSON
download
home_pagehttps://github.com/alethiophile/qtoml
SummaryNew TOML encoder/decoder
upload_time2021-09-11 19:49:53
maintainer
docs_urlNone
authoralethiophile
requires_python>=3.6,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            *****
qTOML
*****

qtoml is another Python TOML encoder/decoder. I wrote it because I found
uiri/toml too unstable, and PyTOML too slow.

For information concerning the TOML language, see `toml-lang/toml <https://github.com/toml-lang/toml>`_.

qtoml currently supports TOML v0.5.0.

Usage
=====

qtoml is available on `PyPI <https://pypi.org/project/qtoml/>`_. You can install
it using pip:

.. code:: bash

  $ pip install qtoml

qtoml supports the standard ``load``/``loads``/``dump``/``dumps`` API common to
most similar modules. Usage:

.. code:: pycon

  >>> import qtoml
  >>> toml_string = """
  ... test_value = 7
  ... """
  >>> qtoml.loads(toml_string)
  {'test_value': 7}
  >>> print(qtoml.dumps({'a': 4, 'b': 5.0}))
  a = 4
  b = 5.0
  
  >>> infile = open('filename.toml', 'r')
  >>> parsed_structure = qtoml.load(infile)
  >>> outfile = open('new_filename.toml', 'w')
  >>> qtoml.dump(parsed_structure, outfile)

TOML supports a fairly complete subset of the Python data model, but notably
does not include a null or ``None`` value. If you have a large dictionary from
somewhere else including ``None`` values, it can occasionally be useful to
substitute them on encode:

.. code:: pycon

  >>> print(qtoml.dumps({ 'none': None }))
  qtoml.encoder.TOMLEncodeError: TOML cannot encode None
  >>> print(qtoml.dumps({ 'none': None }, encode_none='None'))
  none = 'None'

The ``encode_none`` value must be a replacement encodable by TOML, such as zero
or a string.

This breaks reversibility of the encoding, by rendering ``None`` values
indistinguishable from literal occurrences of whatever sentinel you chose. Thus,
it should not be used when exact representations are critical.

Development/testing
===================

qtoml uses the `poetry <https://github.com/sdispater/poetry>`_ tool for project
management. To check out the project for development, run:

.. code:: bash

  $ git clone --recurse-submodules https://github.com/alethiophile/qtoml
  $ cd qtoml
  $ poetry install

This assumes poetry is already installed. The package and dependencies will be
installed in the currently active virtualenv if there is one, or a
project-specific new one created if not.

qtoml is tested against the `alethiophile/toml-test
<https://github.com/alethiophile/toml-test>`_ test suite, forked from uiri's
fork of the original by BurntSushi. To run the tests, after checking out the
project as shown above, enter the ``tests`` directory and run:

.. code:: bash

  $ pytest              # if you already had a virtualenv active
  $ poetry run pytest   # if you didn't

License
=======

This project is available under the terms of the MIT license.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/alethiophile/qtoml",
    "name": "qtoml",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "alethiophile",
    "author_email": "tomdicksonhunt@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/eb/0e/31e7e1288de5ccb891c4d39092e02b955306f2a648e4354cb62faef4b987/qtoml-0.3.1.tar.gz",
    "platform": "",
    "description": "*****\nqTOML\n*****\n\nqtoml is another Python TOML encoder/decoder. I wrote it because I found\nuiri/toml too unstable, and PyTOML too slow.\n\nFor information concerning the TOML language, see `toml-lang/toml <https://github.com/toml-lang/toml>`_.\n\nqtoml currently supports TOML v0.5.0.\n\nUsage\n=====\n\nqtoml is available on `PyPI <https://pypi.org/project/qtoml/>`_. You can install\nit using pip:\n\n.. code:: bash\n\n  $ pip install qtoml\n\nqtoml supports the standard ``load``/``loads``/``dump``/``dumps`` API common to\nmost similar modules. Usage:\n\n.. code:: pycon\n\n  >>> import qtoml\n  >>> toml_string = \"\"\"\n  ... test_value = 7\n  ... \"\"\"\n  >>> qtoml.loads(toml_string)\n  {'test_value': 7}\n  >>> print(qtoml.dumps({'a': 4, 'b': 5.0}))\n  a = 4\n  b = 5.0\n  \n  >>> infile = open('filename.toml', 'r')\n  >>> parsed_structure = qtoml.load(infile)\n  >>> outfile = open('new_filename.toml', 'w')\n  >>> qtoml.dump(parsed_structure, outfile)\n\nTOML supports a fairly complete subset of the Python data model, but notably\ndoes not include a null or ``None`` value. If you have a large dictionary from\nsomewhere else including ``None`` values, it can occasionally be useful to\nsubstitute them on encode:\n\n.. code:: pycon\n\n  >>> print(qtoml.dumps({ 'none': None }))\n  qtoml.encoder.TOMLEncodeError: TOML cannot encode None\n  >>> print(qtoml.dumps({ 'none': None }, encode_none='None'))\n  none = 'None'\n\nThe ``encode_none`` value must be a replacement encodable by TOML, such as zero\nor a string.\n\nThis breaks reversibility of the encoding, by rendering ``None`` values\nindistinguishable from literal occurrences of whatever sentinel you chose. Thus,\nit should not be used when exact representations are critical.\n\nDevelopment/testing\n===================\n\nqtoml uses the `poetry <https://github.com/sdispater/poetry>`_ tool for project\nmanagement. To check out the project for development, run:\n\n.. code:: bash\n\n  $ git clone --recurse-submodules https://github.com/alethiophile/qtoml\n  $ cd qtoml\n  $ poetry install\n\nThis assumes poetry is already installed. The package and dependencies will be\ninstalled in the currently active virtualenv if there is one, or a\nproject-specific new one created if not.\n\nqtoml is tested against the `alethiophile/toml-test\n<https://github.com/alethiophile/toml-test>`_ test suite, forked from uiri's\nfork of the original by BurntSushi. To run the tests, after checking out the\nproject as shown above, enter the ``tests`` directory and run:\n\n.. code:: bash\n\n  $ pytest              # if you already had a virtualenv active\n  $ poetry run pytest   # if you didn't\n\nLicense\n=======\n\nThis project is available under the terms of the MIT license.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "New TOML encoder/decoder",
    "version": "0.3.1",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "25d4222dbd3e7f1fbd42967cef9cf283",
                "sha256": "de4ec4f759a77931cda324a06e2c2fbbb2209372c42f4741c2ab6748f15640b4"
            },
            "downloads": -1,
            "filename": "qtoml-0.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "25d4222dbd3e7f1fbd42967cef9cf283",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6,<4.0",
            "size": 12679,
            "upload_time": "2021-09-11T19:49:51",
            "upload_time_iso_8601": "2021-09-11T19:49:51.500231Z",
            "url": "https://files.pythonhosted.org/packages/7e/34/1ba4ace17418b5285d946468d43801935042119985b013d9fedc260eb21d/qtoml-0.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "cad04134d81bcc39c448bf53892f742b",
                "sha256": "7f2d0c2c39659d2a408ae93d02a068e0d22eb67e16e474239f7735ff1094b1ba"
            },
            "downloads": -1,
            "filename": "qtoml-0.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "cad04134d81bcc39c448bf53892f742b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6,<4.0",
            "size": 13158,
            "upload_time": "2021-09-11T19:49:53",
            "upload_time_iso_8601": "2021-09-11T19:49:53.008405Z",
            "url": "https://files.pythonhosted.org/packages/eb/0e/31e7e1288de5ccb891c4d39092e02b955306f2a648e4354cb62faef4b987/qtoml-0.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-09-11 19:49:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "alethiophile",
    "github_project": "qtoml",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "qtoml"
}
        
Elapsed time: 0.02493s