Fast data traversal & manipulation tools.
Project description
traversy
Fast data traversal & manipulation tools for Python. Check out the documentation.
Quick-Start
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.
Changelog
-
11/15/2020 - 0.1.32 : Fix for pypi.
-
11/15/2020 - 0.1.3 : Refactored & added more utility methods. Added docs.
-
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.32.tar.gz
(4.2 kB
view hashes)
Built Distribution
Close
Hashes for traversy-0.1.32-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fbbfd5a04f744df8810753990d8bbe9e58f5ddd679b82b5e851de35fbec0b4b8 |
|
MD5 | 2e658f9a3f98c3002df31656cb5165e2 |
|
BLAKE2b-256 | 8cacb7431f5217a472334f88a8c409b09a4547e9228da82820d4b7dc386f6158 |