• Stars
    star
    346
  • Rank 122,430 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created over 4 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Human readable and writable data interchange format

NestedText — A Human Friendly Data Format

https://pepy.tech/badge/nestedtext/month https://coveralls.io/repos/github/KenKundert/nestedtext/badge.svg?branch=master
Authors: Ken & Kale Kundert
Version: 3.6
Released: 2023-05-30
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, dates, etc.) may seem counter productive, it leads to simpler data files and applications that are more robust.

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

# 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: [email protected]
    additional roles:
        - board member

Margaret Hodge:
    position: vice president
    address:
        > 2586 Marigold Lane
        > Topeka, Kansas 20682
    phone: 1-470-555-0398
    email: [email protected]
    additional roles:
        - new membership task force
        - accounting task force

A strength of NestedText is its lack of quoting and escaping, making it particularly nice for holding code fragments. Here is another example of NestedText that shows off this feature. It holds some Parametrize From File test cases for pytest. In this case a command line program is being tested and its response is checked using regular expressions:

-
    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 list
    expected: home-\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d
    expected_type: regex
-
    cmd: emborg --quiet borg list --glob-archives "home-*" --short @repo
    expected: home-\d\d\d\d-\d\d-\d\dT\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

One particularly attractive use-case for NestedText is command line programs whose output is meant to be consumed by either people or programs. Many programs do so 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: [email protected]
Margaret Hodge: [email protected]

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. It is especially suitable for configuration files.

More Repositories

1

emborg

Interactive command line interface to Borg Backup
Python
94
star
2

quantiphy

Physical quantities
Python
65
star
3

psf_utils

Read Spectre PSF files
Python
49
star
4

svg_schematic

Generate SVG schematics and block diagrams without a mouse.
Python
25
star
5

sshconfig

An SSH config file generator
Python
23
star
6

flicker-noise

How to correctly write a flicker-noise model for RF simulation.
Python
19
star
7

rlc_chart

A library that renders impedance charts that include capacitance and inductance grids.
Python
13
star
8

avendesora

Command line collaborative password manager & generator
Python
13
star
9

shlib

shell library
Python
9
star
10

tvm

Time Value of Money
Python
8
star
11

inform

Library of print utilities used when outputting messages for the user from command-line programs.
Python
7
star
12

ec

Engineering Calculator
Python
6
star
13

nestedtext_tests

Python
5
star
14

vdiff

Interactive file diff tool based on vim
Python
5
star
15

cryptocurrency

Tracks and values a cryptocurrency portfolio
Python
5
star
16

borg-space

Accessory for Emborg used to report and track the size of your Borg repositories
Python
4
star
17

rkm_codes

Number format for compact robust labels
Python
4
star
18

postmortem

Generates packets of useful information for partners and trustees to be opened upon death
Python
4
star
19

addsshkeys

Add keys to SSH Agent
Python
4
star
20

networth

summarize your networth
Python
4
star
21

remind

Schedule notification reminders from the command line
Python
3
star
22

fvi

Vim paired with grep
Python
3
star
23

generate-dnscrypt-cmdline

Generate compand line used to run dnscrypt
Python
3
star
24

radioshark

Utilities for use with Griffin Technologies RadioSHARK
Python
3
star
25

scripts

A light-weight package that allows users to do shell-script like things relatively easily in Python.
Python
3
star
26

metadata

Programs for extracting and updating the metadata for audio files.
Python
2
star
27

extended_pathlib

Extensions to stdlib pathlib
Python
2
star
28

excavate

understand disk usage over time
Python
2
star
29

bump

similar to bumpversion, but allows updating the release date
Python
2
star
30

avendesora-export

Exports Avendesora accounts to satellite hosts
Python
2
star
31

kodi-control

Interactive TTY-based remote control for Kodi
Python
2
star
32

ntlog

a NestedText logfile aggregation utility
Python
2
star
33

engfmt

Read and write in engineering notation
Python
2
star
34

quantiphy_eval

Python
1
star
35

dump

Simplified command line interface for duplicity
Python
1
star
36

mp

Music Player
Python
1
star
37

bw-export

Export Avendesora Accounts to BitWarden
Python
1
star
38

why-invest-in-bitcoin

The case for bitcoin
Python
1
star