# sendero
Data Filtering for Humans
## why sendero?
"sendero" means footpath in Spanish
## install
```bash
pip install sendero
```
## basic usage
```python
# in JSON-compatible format
data = {
"agency": "GSA",
"measurementType": {
"method": "modules"
},
"version": "2.0.0",
"releases": [
{
"name": "usasearch",
"description": "System now maintained in open repo https://github.com/GSA/search-gov.",
"permissions": {
"licenses": None,
"usageType": "governmentWideReuse"
},
"tags": [
"GSA"
]
},
# ...
]
}
```
```python
from sendero import list_paths, get
list_paths(data, 'agency')
[
"agency",
"measurementType.method",
"releases.contact.email",
"releases.description",
# ...
]
get(data, 'agency')
["GSA"]
# get nested properties using dot syntax
get(data, 'releases.permissions.licenses.name')
["CC0 1.0 Universal", "PD", "agpl-3.0", ... ]
# get nested properties using double underscore syntax
get(data, 'releases__permissions__licenses__name')
["CC0 1.0 Universal", "PD", "agpl-3.0", ... ]
```
# advanced usage
## clean
Filter out None and empty strings.
```python
from sendero import get
# dirty
get(data, "releases.license", clean=False)
[ null, 'https://creativecommons.org/publicdomain/zero/1.0', None, None, ... ]
# clean
get(data, "releases.license", clean=True)
[ 'https://creativecommons.org/publicdomain/zero/1.0', 'https://github.com/GSA/open.gsa.gov/blob/gh-pages/TERMS.md', ... ]
```
## unique
If you only want unique results returned:
```python
# default
get(data, 'releases.tags')
["GSA", "GSA", "GSA", ...]
# uniques only
get(data, 'releases.tags', unique=True)
["GSA","gsa","socialmedia", "mobileapps", ...]
```
## sort
If you want your results sorted
```python
get(data, 'releases.tags', sort=True)
["508", "API", "Bing", "DigitalGovSearch", ...]
```
## delimiter
By default, sendero tries syntax where the steps are separted by
`"."` or `"__"`. If you'd like to restrict the syntax or use a custom delimiter:
```python
get(data, 'releases--tags', delimiter='--')
# accepts releases--tags and releases__tags
get(data, 'releases--tags', delimiter=['--', '__'])
```
## stringify
```python
# converts numbers to strings
get(data, "releases.laborHours", stringify=True, unique=True)
["0", "200", "12345" ]
# convert objects to JSON strings
get(data, "releases.permissions", stringify=True, unique=True)
[
'{"licenses":null,"usageType":"governmentWideReuse"}',
'{"licenses":[{"URL":"http://choosealicense.com/licenses/mit/","name":"mit"}],"usageType":"openSource"}',
'{"licenses":[{"URL":"http://choosealicense.com/licenses/gpl-3.0/","name":"gpl-3.0"}],"usageType":"openSource"}',
'{"licenses":null,"usageType":"openSource"}',
# ...
]
```
Raw data
{
"_id": null,
"home_page": "https://github.com/DanielJDufour/sendero",
"name": "sendero",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "data, filter, path",
"author": "Daniel J. Dufour",
"author_email": "daniel.j.dufour@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/aa/71/8f756dd00b6c1c17fdfe8284e9f382549d214cb5795d7282f723560cd7ee/sendero-0.1.0.tar.gz",
"platform": null,
"description": "# sendero\nData Filtering for Humans\n\n## why sendero?\n\"sendero\" means footpath in Spanish\n\n## install\n```bash\npip install sendero\n```\n\n## basic usage\n```python\n# in JSON-compatible format\ndata = {\n \"agency\": \"GSA\",\n \"measurementType\": {\n \"method\": \"modules\"\n },\n \"version\": \"2.0.0\",\n \"releases\": [\n {\n \"name\": \"usasearch\",\n \"description\": \"System now maintained in open repo https://github.com/GSA/search-gov.\",\n \"permissions\": {\n \"licenses\": None,\n \"usageType\": \"governmentWideReuse\"\n },\n \"tags\": [\n \"GSA\"\n ]\n },\n # ...\n ]\n}\n```\n\n```python\nfrom sendero import list_paths, get\n\nlist_paths(data, 'agency')\n[\n \"agency\",\n \"measurementType.method\",\n \"releases.contact.email\",\n \"releases.description\",\n # ...\n]\n\nget(data, 'agency')\n[\"GSA\"]\n\n# get nested properties using dot syntax\nget(data, 'releases.permissions.licenses.name')\n[\"CC0 1.0 Universal\", \"PD\", \"agpl-3.0\", ... ]\n\n# get nested properties using double underscore syntax\nget(data, 'releases__permissions__licenses__name')\n[\"CC0 1.0 Universal\", \"PD\", \"agpl-3.0\", ... ]\n```\n\n# advanced usage\n## clean\nFilter out None and empty strings.\n```python\nfrom sendero import get\n\n# dirty\nget(data, \"releases.license\", clean=False)\n[ null, 'https://creativecommons.org/publicdomain/zero/1.0', None, None, ... ]\n\n# clean\nget(data, \"releases.license\", clean=True)\n[ 'https://creativecommons.org/publicdomain/zero/1.0', 'https://github.com/GSA/open.gsa.gov/blob/gh-pages/TERMS.md', ... ]\n```\n\n## unique\nIf you only want unique results returned:\n```python\n# default\nget(data, 'releases.tags')\n[\"GSA\", \"GSA\", \"GSA\", ...]\n\n# uniques only\nget(data, 'releases.tags', unique=True)\n[\"GSA\",\"gsa\",\"socialmedia\", \"mobileapps\", ...]\n```\n\n## sort\nIf you want your results sorted\n```python\nget(data, 'releases.tags', sort=True)\n[\"508\", \"API\", \"Bing\", \"DigitalGovSearch\", ...]\n```\n\n## delimiter\nBy default, sendero tries syntax where the steps are separted by\n`\".\"` or `\"__\"`. If you'd like to restrict the syntax or use a custom delimiter:\n```python\nget(data, 'releases--tags', delimiter='--')\n\n# accepts releases--tags and releases__tags\nget(data, 'releases--tags', delimiter=['--', '__'])\n```\n\n## stringify\n```python\n# converts numbers to strings\nget(data, \"releases.laborHours\", stringify=True, unique=True)\n[\"0\", \"200\", \"12345\" ]\n\n# convert objects to JSON strings\nget(data, \"releases.permissions\", stringify=True, unique=True)\n[\n '{\"licenses\":null,\"usageType\":\"governmentWideReuse\"}',\n '{\"licenses\":[{\"URL\":\"http://choosealicense.com/licenses/mit/\",\"name\":\"mit\"}],\"usageType\":\"openSource\"}',\n '{\"licenses\":[{\"URL\":\"http://choosealicense.com/licenses/gpl-3.0/\",\"name\":\"gpl-3.0\"}],\"usageType\":\"openSource\"}',\n '{\"licenses\":null,\"usageType\":\"openSource\"}',\n # ...\n]\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "sendero - data filtering for humans",
"version": "0.1.0",
"project_urls": {
"Download": "https://github.com/DanielJDufour/sendero/tarball/download",
"Homepage": "https://github.com/DanielJDufour/sendero"
},
"split_keywords": [
"data",
" filter",
" path"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "aa718f756dd00b6c1c17fdfe8284e9f382549d214cb5795d7282f723560cd7ee",
"md5": "9cc4552491a46da6bd8b727a9c796375",
"sha256": "41cec0d6fd5e1eebdc958d2e7962f4fe58f3635e28e269463e7171f03b2741b3"
},
"downloads": -1,
"filename": "sendero-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "9cc4552491a46da6bd8b727a9c796375",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6435,
"upload_time": "2024-07-20T01:22:38",
"upload_time_iso_8601": "2024-07-20T01:22:38.325195Z",
"url": "https://files.pythonhosted.org/packages/aa/71/8f756dd00b6c1c17fdfe8284e9f382549d214cb5795d7282f723560cd7ee/sendero-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-20 01:22:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "DanielJDufour",
"github_project": "sendero",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "sendero"
}