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
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
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/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
Built Distribution
File details
Details for the file traversy-0.1.2.tar.gz
.
File metadata
- Download URL: traversy-0.1.2.tar.gz
- Upload date:
- Size: 3.9 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 | dacf38d90f37d40e98da6583b2716c0c727764bf63691fb53c0f1542c1a2ffe5 |
|
MD5 | 92d07d6317790beea82260df6685a86b |
|
BLAKE2b-256 | c3f2de9514703bd08a643850781a3768ebf96aca2a85a7f64162e717a171fbc8 |
File details
Details for the file traversy-0.1.2-py2.py3-none-any.whl
.
File metadata
- Download URL: traversy-0.1.2-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.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 | 4213695b51bbbaef5359e32fe001833bfd630bfcdec50e16f405ca1da9664a87 |
|
MD5 | 437fc85f4990f5c711b431e9f94fd5d3 |
|
BLAKE2b-256 | 34edd33676870b141ae4c4294add644bb0e824d18fc6316dc08ba7113c6a6658 |