Skip to main content

nice-datapath User Guide


Talk is cheap. Show me the code

from datapath import value, register_pipe


import datapath


def concat(*args):
    return "".join(args)


def test_value():
    data = {
        "f1": "a",
        "f2": 2,
        "f3": {
            "f4": "b",
            "f5": 3,
            "f6": [
                "l1", "l2", "l3"
            ],
        },
        "f7": [
            {
                "f8": "f8-1",
                "f9": [1, 2, 3]
            },
            {
                "f8": "f8-2",
                "f9": [1, 2, 3]
            },
            {
                "f8": "f8-3",
                "f9": [1, 2, 3]
            }
        ],
        "f10": {
            "f11": [
                [{"f12": [1]}],
                [{"f12": [2]}],
                [{"f12": 3}],
            ]
        },
        "f13": '{"a": 1}',
        "f14": 0.01123,
        "f15": 0.01,
        "f16": 23.79
    }

    datapath.register_pipe("concat", concat)
    assert datapath.value(data, "f1") == "a"
    assert datapath.value(data, "f2") == 2
    assert datapath.value(data, "f2|str") == "2"
    assert datapath.value(data, "f3.f4") == "b"
    assert datapath.value(data, "f3.f5") == 3
    assert datapath.value(data, "f3.f5 | str  ") == "3"
    assert datapath.value(data, "f3.f6") == ["l1", "l2", "l3"]
    assert datapath.value(data, "f3.f6") == ["l1", "l2", "l3"]
    assert datapath.value(data, "f3.f6|jsondump") == '["l1", "l2", "l3"]'
    assert datapath.value(data, "f7.f8") == ["f8-1", "f8-2", "f8-3"]
    assert datapath.value(data, "f7.f9") == [[1, 2, 3], [1, 2, 3], [1, 2, 3]]
    assert datapath.value(data, "f10.f11.f12") == [[[1]], [[2]], [3]]
    assert datapath.value(data, "f13 | jsonload") == {"a": 1}
    assert datapath.value(data, "f14 | %") == "1.123%"
    assert datapath.value(data, "f14 | % 0") == "1%"
    assert datapath.value(data, "f14 | % 1") == "1.1%"
    assert datapath.value(data, "f14 | % 2") == "1.12%"
    assert datapath.value(data, "f14 | % 3") == "1.123%"
    assert datapath.value(data, "f14 | % 4") == "1.1230%"
    assert datapath.value(data, "f14 | % 5") == "1.12300%"
    assert datapath.value(data, "f15 | %") == "1%"
    assert datapath.value(data, "f16 | int") == 23
    assert datapath.value(data, "f16 | float") == 23.79
    assert datapath.value(data, "f16 | str | concat a b c") == "23.79abc"

Release files for nice-datapath 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nice-datapath 0.0.1
File Size Uploaded
nice-datapath-0.0.1.tar.gz 2.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nice-datapath 0.0.1
File Interpreter ABI Platform
nice_datapath-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 5.5 kB

Release files / nice-datapath-0.0.1.tar.gz

Download URL nice-datapath-0.0.1.tar.gz
Size 2.5 kB
Tags Source
SHA-256 checksum
How to use checksums
14c10cd42a5801b69b60279c67733f38beecada19d83de7d243bb1bdd9a26559
BLAKE2b-256 checksum
How to use checksums
f6c6def16d58fb6f72b27d7b9abfaf72695eff20b9754b1638704e68cb83ec75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.1

Release files / nice_datapath-0.0.1-py3-none-any.whl

Download URL nice_datapath-0.0.1-py3-none-any.whl
Size 2.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7424112cf68deff63ed86758f655c8b9410c6193743940d3b6bda108e07cdee0
BLAKE2b-256 checksum
How to use checksums
40906fa8c2575d9b45fa025d91a87adacecf6674f6ed31b301669f26763745b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.1

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page