Skip to main content

Fast data traversal & manipulation tools.

Project description

traversy

Fast data traversal & manipulation tools for Python.

traverse(data): Traverse deep data structures such as dict, mo-dots, and dotty_dict. Supports nested lists & data.

from traversy import traverse
import json


jo = json.loads("""{
  "2019": {
    "uat": {
      "pkey": true,
      "user": "testval",
      "testkey": true,
      "mylist": [
      {
        "foo": "bar",
        "foo2": "bar2"
      },
      {
        "baz": "milk",
        "bar": "foo"
      }
      ]
    },
    "dev": {
      "pkey": true,
      "testval": "testval",
      "testval2": true
    },
    "test1": [1, 2, "testval"],
    "test2": [{"one": "foo", "two": "bar", "three": "testval"}]
  }
}""")

def is_eq(key, val, opath, query):  # Use of a filter func is optional.
    return val == query


for node in traverse(jo, is_eq, query="milk"):
    print("Found", node.key, ':', node.value)  # baz : milk
    print("Full path access:", jo[node.path_str])  # "2019.uat.mylist.1.baz"

For each iteration, traverse() returns a dict or data object of...

{'key', 'value', 'node_path', 'path_str', 'filter_func',
'filter_args': (data, kwargs), 'parent_node', 'output_formatter'}

For more information on these non-built-in data structure (Which are optional to use), check out mo-dots and dotty_dict.

License: MIT

Changelog

  • 11/15/2020 - 0.1.3 : Refactored & added more utility methods.

  • 11/13/2020 - 0.1.2 : Doc correction.

  • 11/13/2020 - 0.1.1 : Deprecated set_output_format() and made package compatible with both Python 2 and Python 3.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

traversy-0.1.3.tar.gz (4.2 kB view details)

Uploaded Source

Built Distributions

traversy-0.1.3-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

traversy-0.1.3-py2.py3-none-any.whl (3.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file traversy-0.1.3.tar.gz.

File metadata

  • Download URL: traversy-0.1.3.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0

File hashes

Hashes for traversy-0.1.3.tar.gz
Algorithm Hash digest
SHA256 fcac8d0ae2a8bf6686262e699108921e3c6640e96e4aea3927caf3519f2b8a92
MD5 b0d2e32c1b49238a781e45f00c83d280
BLAKE2b-256 93f3accdc6c1cec63adf835ec46d4b331df8e49dc9827bac68b4bffe217e85a8

See more details on using hashes here.

File details

Details for the file traversy-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: traversy-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0

File hashes

Hashes for traversy-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3bc16c7c54ae1b5232f8b8f9ff33815d3374f3b6c35ac2e13b94d0871071d299
MD5 427f9926a6f33866bd154b5a45f0ec78
BLAKE2b-256 89a697cc533733a81a22364d06e85ed26bbdd7c7d9b6a2a79d6091998639f6b9

See more details on using hashes here.

File details

Details for the file traversy-0.1.3-py2.py3-none-any.whl.

File metadata

  • Download URL: traversy-0.1.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0

File hashes

Hashes for traversy-0.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3cd68ab275177b9c611b34ba0feeea024c120e563e5dee9f1f940d3f39b946ce
MD5 c73d9f42e555dac07c6e89b3e6315063
BLAKE2b-256 4d506871e6404e9fef3422e8632dce7d4899979be3ce1b98b57d348315eb46e4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page