Resolve paths within nested objects.
Project description
Path Resolver
=============
Resolve paths within nested objects.
# What is Path Resolver?
Path Resolver is a very simple piece of python code that allows you to dynamic resolve deeply-nested (or as shallow as you please)
structures in Python.
# Why would I use this?
Path Resolver was born out of a need to dynamically find data within nested JSON information.
For example, perhaps I want to extract a bunch of information from a dictionary deep within a JSON structure.
I could, for example, simple write a lot of code and hard-coded indexes, key lookups, et cetera.
Or, alternatively, I could use a simple DSL to look up and resolve the items I need. This is what Path Resolver is.
# Example Usage
## Simple Usage
>>> resolve(['testvalue'], 0)
['testvalue']
>>> resolve(['testvalue'], '0')
'testvalue'
>>> resolve(['testvalue'], '*')
['testvalue']
>>> resolve({'key': 'testvalue'}, 'key')
'testvalue'
>>> resolve({'key': 'testvalue'}, '*')
['testvalue']
## Advanced Usage
>>> resolve({'parent': ['one', 'two', 'three']}, 'parent.*')
['one', 'two', 'three']
>>> resolve({'parent': [{'child': 'testvalue1'}]}, 'parent.*.child')
['testvalue1']
>>> resolve({'parent': [{'child': 'testvalue1'}, {'child': 'testvalue2'}]}, 'parent.*.child')
['testvalue1', 'testvalue2']
>>> resolve({'parent': {'child1': 'testvalue1', 'child2': 'testvalue2'}}, 'parent.*')
['testvalue1', 'testvalue2']
=============
Resolve paths within nested objects.
# What is Path Resolver?
Path Resolver is a very simple piece of python code that allows you to dynamic resolve deeply-nested (or as shallow as you please)
structures in Python.
# Why would I use this?
Path Resolver was born out of a need to dynamically find data within nested JSON information.
For example, perhaps I want to extract a bunch of information from a dictionary deep within a JSON structure.
I could, for example, simple write a lot of code and hard-coded indexes, key lookups, et cetera.
Or, alternatively, I could use a simple DSL to look up and resolve the items I need. This is what Path Resolver is.
# Example Usage
## Simple Usage
>>> resolve(['testvalue'], 0)
['testvalue']
>>> resolve(['testvalue'], '0')
'testvalue'
>>> resolve(['testvalue'], '*')
['testvalue']
>>> resolve({'key': 'testvalue'}, 'key')
'testvalue'
>>> resolve({'key': 'testvalue'}, '*')
['testvalue']
## Advanced Usage
>>> resolve({'parent': ['one', 'two', 'three']}, 'parent.*')
['one', 'two', 'three']
>>> resolve({'parent': [{'child': 'testvalue1'}]}, 'parent.*.child')
['testvalue1']
>>> resolve({'parent': [{'child': 'testvalue1'}, {'child': 'testvalue2'}]}, 'parent.*.child')
['testvalue1', 'testvalue2']
>>> resolve({'parent': {'child1': 'testvalue1', 'child2': 'testvalue2'}}, 'parent.*')
['testvalue1', 'testvalue2']
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
pathresolver-0.1.3.tar.gz
(2.4 kB
view hashes)
Built Distributions
pathresolver-0.1.3-py2.7.egg
(3.9 kB
view hashes)
Close
Hashes for pathresolver-0.1.3.linux-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cab2d1d49ca9e26f979e62d8a2b447fdb602ce4d4f41734bbad7990934f8c23 |
|
MD5 | ee74fc2f8cc71b0dd87eadfb37baf25c |
|
BLAKE2b-256 | 8909d80e1f5918c869d4febf214fd343eab7a8f17e3be7fe2b8c3bda92772b0d |