dtab
Config files made of tab-separated paths. One line is one path into a tree.
objects l1,l2 light
deltas l1 position x 1 y .5
z -2
import dtab
dtab.parse(open("scene.dtab").read())
# {'objects': {'l1': 'light', 'l2': 'light'},
# 'deltas': {'l1': {'position': {'x': '1', 'y': '.5', 'z': '-2'}}}}
Why
-
Less to look at. No braces, quotes, or commas between values. A file with its tabs aligned reads like pseudocode, and is easy to write by hand, even on paper.
-
Simple. Six rules, one pass, about 70 lines per implementation.
-
Everything is addressable. There are no lists, so every value has a dotted path:
config.deltas.l1.position.xworks with EasyDict in Python and plain property access in JavaScript. -
You choose the shape. Lines stack, and
c,dwrites one value under several keys, so the same tree can be written wide, deep, or on one line, trading horizontal space for vertical. These are the same file:a b c x a b d xa b c x d xa b c,d x
Rules
- Tabs separate the steps of a path.
deltas l1 positionwalks three keys down. Several tabs in a row count as one, so you can align columns. - An entry with a space is
key value. It sets the key and stays at the same level, sox 1 y .5sets two keys. - An indented line continues the path of the line above it.
- Writing a key again replaces it. Writing into an object merges.
a,bwrites the same value underaand underb.- An entry that starts with a space is a comment.
Every value is a string. Cast the ones you need. Keys are identifiers (letters, digits, underscores),
so attribute access like config.deltas.l1 works with EasyDict and friends.
Install
| Python | pip install dtab then import dtab |
| JavaScript | npm install dtab then const dtab = require('dtab'), or <script src="https://cdn.jsdelivr.net/npm/dtab/dtab.js"> for window.dtab |
| Vim | Plugin 'RyannDaGreat/dtab' (Vundle) or Plug 'RyannDaGreat/dtab' (vim-plug). Or paste dtab.vim into your vimrc. Highlights *.dtab and flags bad keys and trailing tabs. |
API
parse(text)returns nested dicts (Python) or plain objects (JavaScript). Raises on an invalid key, with the line number.stringify(tree)writes the tree back out, one key per line.- Command line:
dtab scene.dtabprints the tree as JSON.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dtab-0.1.0.tar.gz.
File metadata
- Download URL: dtab-0.1.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
846977c4ac0fb14fe1d1969c87fb81fa8c5f303f86d75496cb8415aa824f90d3
|
|
| MD5 |
8a692abae62c5fe525cb7f7c46acc8c1
|
|
| BLAKE2b-256 |
3141f286c42227c505e1d068a2f575afd10a4e7243c1720c0ce500622488b473
|
File details
Details for the file dtab-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dtab-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74a46b04eda206eb4405ee5d9b53f0ab6d7d08c8f3a41978f49a11e1a009d239
|
|
| MD5 |
b60be5bc7a236abe0fe99e5b891813d2
|
|
| BLAKE2b-256 |
0a73b75a08e19c5474ac803f71a28f50dd1023c0f02ec23c94128080e78b2f52
|