Fast data traversal & manipulation tools.
Project description
traversy
Fast data traversal & manipulation tools for Python.
traverse()
:
Traverse deep data structures such as dict, mo-dots, and
dotty_dict. Supports nested lists & data.
from traversy import traverse, set_output_format
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):
return val == query
set_output_format('mo-dots') # Can be dict (Default), mo-dots, or dotty_dict
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'}
For more information on these non-built-in data structure (Which are optional to use), check out mo-dots and dotty_dict.
License: MIT
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.0.tar.gz
(3.6 kB
view details)
Built Distribution
File details
Details for the file traversy-0.1.0.tar.gz
.
File metadata
- Download URL: traversy-0.1.0.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e602af1163438e758772b304935ee08950ebec9c86ec2431aba15252563ebf59 |
|
MD5 | d9fe641e6f8426db791db94611ed9e63 |
|
BLAKE2b-256 | 5fbf5d484bccd0106b7da144c4d77a87a5f49065721a12a5107a3f723cb301c8 |
File details
Details for the file traversy-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: traversy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15e34df72b5702c4720842f140002092db4bc7d9fb54000e66cef137ee869745 |
|
MD5 | 1c1b441c1e5f34dace182b4c6167c5df |
|
BLAKE2b-256 | be99840893ae6f2934d8b297789ff69383c04b7c8b2e9b019ad300e2e587a862 |