nestedtext


Namenestedtext JSON
Version 3.7 PyPI version JSON
download
home_pageNone
Summaryhuman readable and writable data interchange format
upload_time2024-04-28 01:12:54
maintainerNone
docs_urlNone
authorKen Kundert, Kale Kundert
requires_python>=3.6
licenseNone
keywords data serialization json yaml
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage
            NestedText — A Human Friendly Data Format
=========================================

|downloads| |build status| |coverage| |rtd status| |pypi version| |anaconda version| |python version|


| Authors: Ken & Kale Kundert
| Version: 3.7
| Released: 2024-04-27
| Documentation: nestedtext.org_
| Please post all questions, suggestions, and bug reports to GitHub_.
|

*NestedText* is a file format for holding structured data.  It is similar in 
concept to JSON_, except that *NestedText* is designed to make it easy for 
people to enter, edit, or view the data directly.  It organizes the data into 
a nested collection of name-value pairs, lists, and strings.  The syntax is 
intended to be very simple and intuitive for most people.

A unique feature of this file format is that it only supports one scalar type: 
strings.  As such, quoting strings is unnecessary, and without quoting there is 
no need for escaping.  While the decision to forego other types (integers, 
reals, Booleans, etc.) may seem counter productive, it leads to simpler data 
files and applications that are more robust.

*NestedText* is convenient for configuration files, data journals, address 
books, account information, and the like.  Here is an example of a file that 
contains a few addresses:

.. code-block:: nestedtext

    # Contact information for our officers

    Katheryn McDaniel:
        position: president
        address:
            > 138 Almond Street
            > Topeka, Kansas 20697
        phone:
            cell: 1-210-555-5297
            home: 1-210-555-8470
                # Katheryn prefers that we always call her on her cell phone.
        email: KateMcD@aol.com
        additional roles:
            - board member

    Margaret Hodge:
        position: vice president
        address:
            > 2586 Marigold Lane
            > Topeka, Kansas 20682
        phone: 1-470-555-0398
        email: margaret.hodge@ku.edu
        additional roles:
            - new membership task force
            - accounting task force

Typical Applications
--------------------

Configuration
"""""""""""""

Configuration files are an attractive application for *NestedText*.  
*NestedText* configuration files tend to be simple, clean and unambiguous.  
Plus, they handle hierarchy much better than alternatives such as Ini_ and 
TOML_.


Structured Code
"""""""""""""""

One way to build tools to tackle difficult and complex tasks is to provide an 
application specific language.  That can be a daunting challenge.  However, in 
certain cases, such as specifying complex configurations, *NestedText* can help 
make the task much easier.  *NestedText* conveys the structure of data leaving 
the end application to interpret the data itself.  It can do so with 
a collection of small parsers that are tailored to the specific piece of data to 
which they are applied.  This generally results in a simpler specification since 
each piece of data can be given in its natural format, which might otherwise 
confuse a shared parser.  In this way, rather than building one large very 
general language and parser, a series of much smaller and simpler parsers are 
needed.  These smaller parsers can be as simple as splitters or partitioners, 
value checkers, or converters for numbers in special forms (numbers with units, 
times or dates, GPS coordinates, etc.).  Or they could be full-blown expression 
evaluators or mini-languages.  Structured code provides a nice middle ground 
between data and code and its use is growing in popularity.

An example of structured code is provided by GitHub with its workflow 
specification files.  They use YAML_.  Unfortunately, the syntax of the code 
snippets held in the various fields can be confused with *YAML* syntax, which 
leads to unnecessary errors, confusion, and complexity (see *YAML issues*).  
JSON_ suffers from similar problems.  *NestedText* excels for these applications 
as it holds code snippets without any need for quoting or escaping.  
*NestedText* provides simple unambiguous rules for defining the structure of 
your data and when these rules are followed there is no way for any syntax or 
special characters in the values of your data to be confused with *NestedText* 
syntax.  In fact, it is possible for *NestedText* to hold *NestedText* snippets 
without conflict.

Another example of structured code is provided by the files that contain the 
test cases used by `Parametrize From File`_, a PyTest_ plugin.
*Parametrize From File* simplifies the task of specifying test cases for 
*PyTest* by separating the test cases from the test code.  Here it is being 
applied to test a command line program.  Its response is checked using regular 
expressions.  Each entry includes a shell command to run the program and 
a regular expression that must match the output for the test to pass::

    -
        cmd: emborg version
        expected: emborg version: \d+\.\d+(\.\d+(\.?\w+\d+)?)?  \(\d\d\d\d-\d\d-\d\d\)
        expected type: regex
    -
        cmd: emborg --quiet files -D
        expected:
            > Archive: home-\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d
            > \d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d.\d\d\d\d\d\d configs/subdir/(file|)
            > \d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d.\d\d\d\d\d\d configs/subdir/(file|)
                # Unfortunately, we cannot check the order as they were both 
                # created at the same time.
        expected type: regex
    -
        cmd: emborg due --backup-days 1 --message "{elapsed} since last {action}"
        expected: home: (\d+(\.\d)? (seconds|minutes)) since last backup\.
        expected type: regex

Notice that the regular expressions are given clean, without any quoting or 
escaping.


Composable Utilities
""""""""""""""""""""

Another attractive use-case for *NestedText* is command line programs whose 
output is meant to be consumed by either people or other programs.  This is 
another growing trend.  Many programs do this by supporting a ``--json`` 
command-line flag that indicates the output should be computer readable rather 
than human readable.  But, with *NestedText* it is not necessary to make people 
choose.  Just output the result in *NestedText* and it can be read by people or 
computers.  For example, consider a program that reads your address list and 
output particular fields on demand::

    > address --email
    Katheryn McDaniel: KateMcD@aol.com
    Margaret Hodge: margaret.hodge@ku.edu

This output could be fed directly into another program that accepts *NestedText* 
as input::

    > address --email | mail-to-list


Contributing
------------

This package contains a Python reference implementation of *NestedText* and 
a test suite.  Implementation in many languages is required for *NestedText* to 
catch on widely.  If you like the format, please consider contributing 
additional implementations.

Also, please consider using *NestedText* for any applications you create.


.. _json: https://www.json.org/json-en.html
.. _yaml: https://yaml.org/
.. _toml: https://toml.io/en/
.. _ini: https://en.wikipedia.org/wiki/INI_file
.. _parametrize from file: https://parametrize-from-file.readthedocs.io
.. _pytest: https://docs.pytest.org
.. _github: https://github.com/KenKundert/nestedtext/issues
.. _nestedtext.org: https://nestedtext.org

.. |downloads| image:: https://pepy.tech/badge/nestedtext/month
    :target: https://pepy.tech/project/nestedtext

.. |rtd status| image:: https://img.shields.io/readthedocs/nestedtext.svg
   :target: https://nestedtext.readthedocs.io/en/latest/?badge=latest

.. |build status| image:: https://github.com/KenKundert/nestedtext/actions/workflows/build.yaml/badge.svg
    :target: https://github.com/KenKundert/nestedtext/actions/workflows/build.yaml

.. |coverage| image:: https://coveralls.io/repos/github/KenKundert/nestedtext/badge.svg?branch=master
    :target: https://coveralls.io/github/KenKundert/nestedtext?branch=master

.. |pypi version| image:: https://img.shields.io/pypi/v/nestedtext.svg
    :target: https://pypi.python.org/pypi/nestedtext

.. |anaconda version| image:: https://anaconda.org/conda-forge/nestedtext/badges/version.svg
    :target: https://anaconda.org/conda-forge/nestedtext

.. |python version| image:: https://img.shields.io/pypi/pyversions/nestedtext.svg
    :target: https://pypi.python.org/pypi/nestedtext



            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "nestedtext",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "data, serialization, json, yaml",
    "author": "Ken Kundert, Kale Kundert",
    "author_email": "nestedtext@nurdletech.com",
    "download_url": "https://files.pythonhosted.org/packages/4f/e0/0315d81778e63a90e389e849979728bac723c5f814c96f1c5b6a5f47584c/nestedtext-3.7.tar.gz",
    "platform": null,
    "description": "NestedText \u2014 A Human Friendly Data Format\n=========================================\n\n|downloads| |build status| |coverage| |rtd status| |pypi version| |anaconda version| |python version|\n\n\n| Authors: Ken & Kale Kundert\n| Version: 3.7\n| Released: 2024-04-27\n| Documentation: nestedtext.org_\n| Please post all questions, suggestions, and bug reports to GitHub_.\n|\n\n*NestedText* is a file format for holding structured data.  It is similar in \nconcept to JSON_, except that *NestedText* is designed to make it easy for \npeople to enter, edit, or view the data directly.  It organizes the data into \na nested collection of name-value pairs, lists, and strings.  The syntax is \nintended to be very simple and intuitive for most people.\n\nA unique feature of this file format is that it only supports one scalar type: \nstrings.\u00a0 As such, quoting strings is unnecessary, and without quoting there is \nno need for escaping.  While the decision to forego other types (integers, \nreals, Booleans, etc.) may seem counter productive, it leads to simpler data \nfiles and applications that are more robust.\n\n*NestedText* is convenient for configuration files, data journals, address \nbooks, account information, and the like.  Here is an example of a file that \ncontains a few addresses:\n\n.. code-block:: nestedtext\n\n    # Contact information for our officers\n\n    Katheryn McDaniel:\n        position: president\n        address:\n            > 138 Almond Street\n            > Topeka, Kansas 20697\n        phone:\n            cell: 1-210-555-5297\n            home: 1-210-555-8470\n                # Katheryn prefers that we always call her on her cell phone.\n        email: KateMcD@aol.com\n        additional roles:\n            - board member\n\n    Margaret Hodge:\n        position: vice president\n        address:\n            > 2586 Marigold Lane\n            > Topeka, Kansas 20682\n        phone: 1-470-555-0398\n        email: margaret.hodge@ku.edu\n        additional roles:\n            - new membership task force\n            - accounting task force\n\nTypical Applications\n--------------------\n\nConfiguration\n\"\"\"\"\"\"\"\"\"\"\"\"\"\n\nConfiguration files are an attractive application for *NestedText*.  \n*NestedText* configuration files tend to be simple, clean and unambiguous.  \nPlus, they handle hierarchy much better than alternatives such as Ini_ and \nTOML_.\n\n\nStructured Code\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n\nOne way to build tools to tackle difficult and complex tasks is to provide an \napplication specific language.  That can be a daunting challenge.  However, in \ncertain cases, such as specifying complex configurations, *NestedText* can help \nmake the task much easier.  *NestedText* conveys the structure of data leaving \nthe end application to interpret the data itself.  It can do so with \na collection of small parsers that are tailored to the specific piece of data to \nwhich they are applied.  This generally results in a simpler specification since \neach piece of data can be given in its natural format, which might otherwise \nconfuse a shared parser.  In this way, rather than building one large very \ngeneral language and parser, a series of much smaller and simpler parsers are \nneeded.  These smaller parsers can be as simple as splitters or partitioners, \nvalue checkers, or converters for numbers in special forms (numbers with units, \ntimes or dates, GPS coordinates, etc.).  Or they could be full-blown expression \nevaluators or mini-languages.  Structured code provides a nice middle ground \nbetween data and code and its use is growing in popularity.\n\nAn example of structured code is provided by GitHub with its workflow \nspecification files.  They use YAML_.  Unfortunately, the syntax of the code \nsnippets held in the various fields can be confused with *YAML* syntax, which \nleads to unnecessary errors, confusion, and complexity (see *YAML issues*).  \nJSON_ suffers from similar problems.  *NestedText* excels for these applications \nas it holds code snippets without any need for quoting or escaping.  \n*NestedText* provides simple unambiguous rules for defining the structure of \nyour data and when these rules are followed there is no way for any syntax or \nspecial characters in the values of your data to be confused with *NestedText* \nsyntax.  In fact, it is possible for *NestedText* to hold *NestedText* snippets \nwithout conflict.\n\nAnother example of structured code is provided by the files that contain the \ntest cases used by `Parametrize From File`_, a PyTest_ plugin.\n*Parametrize From File* simplifies the task of specifying test cases for \n*PyTest* by separating the test cases from the test code.  Here it is being \napplied to test a command line program.  Its response is checked using regular \nexpressions.  Each entry includes a shell command to run the program and \na regular expression that must match the output for the test to pass::\n\n    -\n        cmd: emborg version\n        expected: emborg version: \\d+\\.\\d+(\\.\\d+(\\.?\\w+\\d+)?)?  \\(\\d\\d\\d\\d-\\d\\d-\\d\\d\\)\n        expected type: regex\n    -\n        cmd: emborg --quiet files -D\n        expected:\n            > Archive: home-\\d\\d\\d\\d-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d\n            > \\d\\d\\d\\d-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d.\\d\\d\\d\\d\\d\\d configs/subdir/(file|)\n            > \\d\\d\\d\\d-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d.\\d\\d\\d\\d\\d\\d configs/subdir/(file|)\n                # Unfortunately, we cannot check the order as they were both \n                # created at the same time.\n        expected type: regex\n    -\n        cmd: emborg due --backup-days 1 --message \"{elapsed} since last {action}\"\n        expected: home: (\\d+(\\.\\d)? (seconds|minutes)) since last backup\\.\n        expected type: regex\n\nNotice that the regular expressions are given clean, without any quoting or \nescaping.\n\n\nComposable Utilities\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n\nAnother attractive use-case for *NestedText* is command line programs whose \noutput is meant to be consumed by either people or other programs.  This is \nanother growing trend.  Many programs do this by supporting a ``--json`` \ncommand-line flag that indicates the output should be computer readable rather \nthan human readable.  But, with *NestedText* it is not necessary to make people \nchoose.  Just output the result in *NestedText* and it can be read by people or \ncomputers.  For example, consider a program that reads your address list and \noutput particular fields on demand::\n\n    > address --email\n    Katheryn McDaniel: KateMcD@aol.com\n    Margaret Hodge: margaret.hodge@ku.edu\n\nThis output could be fed directly into another program that accepts *NestedText* \nas input::\n\n    > address --email | mail-to-list\n\n\nContributing\n------------\n\nThis package contains a Python reference implementation of *NestedText* and \na test suite.  Implementation in many languages is required for *NestedText* to \ncatch on widely.  If you like the format, please consider contributing \nadditional implementations.\n\nAlso, please consider using *NestedText* for any applications you create.\n\n\n.. _json: https://www.json.org/json-en.html\n.. _yaml: https://yaml.org/\n.. _toml: https://toml.io/en/\n.. _ini: https://en.wikipedia.org/wiki/INI_file\n.. _parametrize from file: https://parametrize-from-file.readthedocs.io\n.. _pytest: https://docs.pytest.org\n.. _github: https://github.com/KenKundert/nestedtext/issues\n.. _nestedtext.org: https://nestedtext.org\n\n.. |downloads| image:: https://pepy.tech/badge/nestedtext/month\n    :target: https://pepy.tech/project/nestedtext\n\n.. |rtd status| image:: https://img.shields.io/readthedocs/nestedtext.svg\n   :target: https://nestedtext.readthedocs.io/en/latest/?badge=latest\n\n.. |build status| image:: https://github.com/KenKundert/nestedtext/actions/workflows/build.yaml/badge.svg\n    :target: https://github.com/KenKundert/nestedtext/actions/workflows/build.yaml\n\n.. |coverage| image:: https://coveralls.io/repos/github/KenKundert/nestedtext/badge.svg?branch=master\n    :target: https://coveralls.io/github/KenKundert/nestedtext?branch=master\n\n.. |pypi version| image:: https://img.shields.io/pypi/v/nestedtext.svg\n    :target: https://pypi.python.org/pypi/nestedtext\n\n.. |anaconda version| image:: https://anaconda.org/conda-forge/nestedtext/badges/version.svg\n    :target: https://anaconda.org/conda-forge/nestedtext\n\n.. |python version| image:: https://img.shields.io/pypi/pyversions/nestedtext.svg\n    :target: https://pypi.python.org/pypi/nestedtext\n\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "human readable and writable data interchange format",
    "version": "3.7",
    "project_urls": {
        "changelog": "https://github.com/KenKundert/nestedtext/blob/master/doc/releases.rst",
        "documentation": "https://nestedtext.org",
        "homepage": "https://nestedtext.org",
        "repository": "https://github.com/kenkundert/nestedtext"
    },
    "split_keywords": [
        "data",
        " serialization",
        " json",
        " yaml"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d5673a1aa909570298b972f0bc3c8f63b2202f4fd6d5d7d389d6a614ad379b30",
                "md5": "f44b5f8d32d818f45e75a16b9bdaa986",
                "sha256": "029d7ceda6096ff84acb26695aea25efbdb71853033ebdacdaf206603b8f89b5"
            },
            "downloads": -1,
            "filename": "nestedtext-3.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f44b5f8d32d818f45e75a16b9bdaa986",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 28822,
            "upload_time": "2024-04-28T01:12:52",
            "upload_time_iso_8601": "2024-04-28T01:12:52.495468Z",
            "url": "https://files.pythonhosted.org/packages/d5/67/3a1aa909570298b972f0bc3c8f63b2202f4fd6d5d7d389d6a614ad379b30/nestedtext-3.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4fe00315d81778e63a90e389e849979728bac723c5f814c96f1c5b6a5f47584c",
                "md5": "6af40c7aa06fbdca68676a4a1968f026",
                "sha256": "0a58fe2789535139b9eb532b7bb6e810e5e288421b061eab6c942839e88a796d"
            },
            "downloads": -1,
            "filename": "nestedtext-3.7.tar.gz",
            "has_sig": false,
            "md5_digest": "6af40c7aa06fbdca68676a4a1968f026",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 30790,
            "upload_time": "2024-04-28T01:12:54",
            "upload_time_iso_8601": "2024-04-28T01:12:54.320673Z",
            "url": "https://files.pythonhosted.org/packages/4f/e0/0315d81778e63a90e389e849979728bac723c5f814c96f1c5b6a5f47584c/nestedtext-3.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-28 01:12:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "KenKundert",
    "github_project": "nestedtext",
    "travis_ci": true,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "nestedtext"
}
        
Elapsed time: 0.24363s