Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering and parsing facilities #1

Open
captain-yoshi opened this issue Apr 3, 2022 · 1 comment
Open

Filtering and parsing facilities #1

captain-yoshi opened this issue Apr 3, 2022 · 1 comment

Comments

@captain-yoshi
Copy link

captain-yoshi commented Apr 3, 2022

Is this library meant to do filtering like the YAML processor yq does ? If it does, I guess I would have to implement the filtering logic (see example below) but that would not be too complicated because of the provided parsing facilities. Speaking of facilities, do you have a function that checks if a YAML node is a subset of another node ?

# Filtering example using 'yq'
# Filters out every data sequences that does not match:
#     query.scene   == "box-1c" && 
#     query.request == "First Contact"
yq 'del(.data[] | select((.query.scene == "box-1c" and .query.request == "First Contact")|not))' < dataset.yaml

YAML file:

data:
- query:
    scene: box-1c
    request: First Contact
- query:
    scene: empty
    request: All Contact
- query:
    scene: empty
    request: First Contact
- query:
    scene: empty
    request: First Contact

After filtering:

data:
- query:
    scene: box-1c
    request: First Contact
@biojppm
Copy link
Owner

biojppm commented Apr 5, 2022

Is this library meant to do filtering like the YAML processor yq does ?

No, filtering is not the intent, and is not contemplated. In terms of importance, modification and replacement of existing nodes is the first objective, adding nodes the second, and removal of nodes is possible but just as an artifact of the first two: assigning an empty node. Selective removal is not considered.

do you have a function that checks if a YAML node is a subset of another node ?

No, sorry. Happy to accept a PR for that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants