# yaml\_pipe
CLI utility for extracting YAML or JSON data.
[GitHub Repo](https://github.com/skovranek/yaml_pipe)
## Overview
You can use YAML\_Pipe as a CLI utility to access and/or search for the key of specific data nodes in a YAML or JSON file. This may help with data processing by not requiring you to, first, manually open and literally read the data file, then then write code in your program to access certain keys to extract the data, and then run your program. YAML\_Pipe let's you grab the data, and then pipe it as input to another CLI tool or write it to a new file. It does not modify the original file.
## Features
![gif demonstrating autocomplete](https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExN3kwOXVxbTlhZjcyOHl6czk5dzFzbzhudHgyejFld2o3bzYwNnJkdCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/7Skla52RfNo837pfvN/giphy.gif)
Usage:
```
$ yaml_pipe [-h/--help] [-q/--quiet]
<file> <enumerate, yaml, or json> <keys...>
[--search <key>] [--type <int, float, bool, bin, null, or timestamp>]
```
'yaml\_pipe' takes three positional arguments, and four options. Provides autocomplete and abbreviation.
- HELP: [-h/--help] Usual help option.
- QUIET: [-q/--quiet] Option to turn off success messages printed to stderr.
- FILE: [file] Must include path to data file to parse as YAML (JSON is a subset of YAML).
- COMMAND: \<enumerate, yaml, or json> Must select one of three commands:
- ENUMERATE: Print the nodes at the current level. No nesting. Index sequences.
- YAML: Output YAML data.
- JSON: Output JSON string.
- KEYS: \<keys ...> Optionally provide keys and/or indices as extra args to access nested nodes. Tab for autocomplete to list keys and indices.
- SEARCH: [--search \<key>] Optionally search for a key. Must match exactly. Default data type is a string.
- TYPE: [--type \<data\_type>] Optionally select the data type of search keys that are not strings. Each choice correlates with a YAML data tag. Is an option for the search option.
> NOTE:
> To ensure autocomplete with argcomplete works as intended, follow the order of arguments found here:
> `$ yaml_pipe -q file command keys... --search key --type data_type`
## Download/Install
From source:
1) Clone the repo:
```
$ git clone https://github.com/skovranek/yaml_pipe
```
2) Change directories to the new 'yaml\_pipe directory/', then run:
```
$ python3 -m pip install -e .
$ eval "$(register-python-argcomplete3 yaml_pipe)"
```
From PyPI:
```
$ pip install pipeyaml
```
> NOTE:
> YAML\_Pipe is published on PyPI as 'pipeyaml', not 'yaml\_pipe' or 'yamlpipe'.
## Implement Library
There are a few different functions from this project you may want to import.
> access\_keys(node: Any, keys: List[str]) -> Any, bool:
Attempt to access value in a series of nested dicts and lists via list of keys and indices as strings. True/False for exists/not exists.
> key\_search(node: Any, key: str) -> Any, List[Any], bool:
Attempt to find dict key in series of nested dicts and lists. Returned list is path of keys or indices to access value. True/False for found/not found.
> print\_keys(node: Any):
Prints the first layer of nodes. Keys are listed. Sequences are indexed. Nested values are printed inline flow style.
View the [main](hhhttps://github.com/skovranek/yaml_pipe/blob/main/requirements.txt) function of Yaml\_Pip for an example of how these functions are used.
## Dependencies
The main dependencies of YAML\_Pipe are [ruamel.yaml](https://pypi.org/project/ruamel.yaml/) to parse YAML and JSON, [argparse](https://docs.python.org/3/library/argparse.html) to parse CLI args, and [argcomplete](https://pypi.org/project/argcomplete/) to autocomplete arguments and options.
View the [requirements.txt](https://github.com/skovranek/yaml_pipe/blob/main/requirements.txt) file for the entire list of dependencies.
## Testing
Manually tested with a zsh shell in the macOS terminal.
## Contact
Questions, issues or suggestions: mattjskov at gmail.com
## Contribute
Anyone is welcome to submit pull requests to the main branch.
Raw data
{
"_id": null,
"home_page": "https://github.com/skovranek/yaml_pipe",
"name": "pipeyaml",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.12.0",
"maintainer_email": "",
"keywords": "yaml json utility extract autocomplete",
"author": "Matt Skovranek",
"author_email": "mattjskov@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/62/55/19f7b590aeeb7bf7d2a3d68e2ae856f01f57e2a7cbe67181595eed8b8952/pipeyaml-0.1.1.tar.gz",
"platform": null,
"description": "# yaml\\_pipe\nCLI utility for extracting YAML or JSON data.\n[GitHub Repo](https://github.com/skovranek/yaml_pipe)\n## Overview\nYou can use YAML\\_Pipe as a CLI utility to access and/or search for the key of specific data nodes in a YAML or JSON file. This may help with data processing by not requiring you to, first, manually open and literally read the data file, then then write code in your program to access certain keys to extract the data, and then run your program. YAML\\_Pipe let's you grab the data, and then pipe it as input to another CLI tool or write it to a new file. It does not modify the original file.\n\n## Features\n![gif demonstrating autocomplete](https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExN3kwOXVxbTlhZjcyOHl6czk5dzFzbzhudHgyejFld2o3bzYwNnJkdCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/7Skla52RfNo837pfvN/giphy.gif)\n\nUsage:\n```\n$ yaml_pipe [-h/--help] [-q/--quiet]\n<file> <enumerate, yaml, or json> <keys...>\n[--search <key>] [--type <int, float, bool, bin, null, or timestamp>]\n```\n'yaml\\_pipe' takes three positional arguments, and four options. Provides autocomplete and abbreviation.\n- HELP: [-h/--help] Usual help option.\n- QUIET: [-q/--quiet] Option to turn off success messages printed to stderr.\n- FILE: [file] Must include path to data file to parse as YAML (JSON is a subset of YAML).\n- COMMAND: \\<enumerate, yaml, or json> Must select one of three commands:\n - ENUMERATE: Print the nodes at the current level. No nesting. Index sequences.\n - YAML: Output YAML data.\n - JSON: Output JSON string.\n- KEYS: \\<keys ...> Optionally provide keys and/or indices as extra args to access nested nodes. Tab for autocomplete to list keys and indices.\n- SEARCH: [--search \\<key>] Optionally search for a key. Must match exactly. Default data type is a string.\n- TYPE: [--type \\<data\\_type>] Optionally select the data type of search keys that are not strings. Each choice correlates with a YAML data tag. Is an option for the search option.\n> NOTE:\n> To ensure autocomplete with argcomplete works as intended, follow the order of arguments found here:\n> `$ yaml_pipe -q file command keys... --search key --type data_type`\n\n## Download/Install\nFrom source:\n1) Clone the repo:\n```\n$ git clone https://github.com/skovranek/yaml_pipe\n```\n2) Change directories to the new 'yaml\\_pipe directory/', then run:\n```\n$ python3 -m pip install -e .\n$ eval \"$(register-python-argcomplete3 yaml_pipe)\"\n```\nFrom PyPI:\n```\n$ pip install pipeyaml\n```\n> NOTE:\n> YAML\\_Pipe is published on PyPI as 'pipeyaml', not 'yaml\\_pipe' or 'yamlpipe'.\n\n## Implement Library\nThere are a few different functions from this project you may want to import.\n> access\\_keys(node: Any, keys: List[str]) -> Any, bool:\n\nAttempt to access value in a series of nested dicts and lists via list of keys and indices as strings. True/False for exists/not exists.\n\n> key\\_search(node: Any, key: str) -> Any, List[Any], bool:\n\nAttempt to find dict key in series of nested dicts and lists. Returned list is path of keys or indices to access value. True/False for found/not found.\n\n> print\\_keys(node: Any):\n\nPrints the first layer of nodes. Keys are listed. Sequences are indexed. Nested values are printed inline flow style.\n\nView the [main](hhhttps://github.com/skovranek/yaml_pipe/blob/main/requirements.txt) function of Yaml\\_Pip for an example of how these functions are used.\n## Dependencies\nThe main dependencies of YAML\\_Pipe are [ruamel.yaml](https://pypi.org/project/ruamel.yaml/) to parse YAML and JSON, [argparse](https://docs.python.org/3/library/argparse.html) to parse CLI args, and [argcomplete](https://pypi.org/project/argcomplete/) to autocomplete arguments and options.\n\nView the [requirements.txt](https://github.com/skovranek/yaml_pipe/blob/main/requirements.txt) file for the entire list of dependencies.\n## Testing\nManually tested with a zsh shell in the macOS terminal.\n\n## Contact\nQuestions, issues or suggestions: mattjskov at gmail.com\n\n## Contribute\nAnyone is welcome to submit pull requests to the main branch.\n",
"bugtrack_url": null,
"license": "GPL-3.0",
"summary": "Access YAML data in the CLI.",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://github.com/skovranek/yaml_pipe"
},
"split_keywords": [
"yaml",
"json",
"utility",
"extract",
"autocomplete"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "625519f7b590aeeb7bf7d2a3d68e2ae856f01f57e2a7cbe67181595eed8b8952",
"md5": "676c996e0f4787a089fff0db2a6eb032",
"sha256": "dd9b24ba6688e8341d018dd85f35ad9a63a239cc88c003d1aa955d55dc25acbd"
},
"downloads": -1,
"filename": "pipeyaml-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "676c996e0f4787a089fff0db2a6eb032",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12.0",
"size": 15639,
"upload_time": "2023-12-04T15:41:24",
"upload_time_iso_8601": "2023-12-04T15:41:24.231731Z",
"url": "https://files.pythonhosted.org/packages/62/55/19f7b590aeeb7bf7d2a3d68e2ae856f01f57e2a7cbe67181595eed8b8952/pipeyaml-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-04 15:41:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "skovranek",
"github_project": "yaml_pipe",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "pipeyaml"
}