Context Provider¶
Hooks that change the context, ie the portion of the tackle file that has been parsed sequentially. Allows referencing of nested keys.
Hooks¶
Type | Description | Return |
---|---|---|
append | Hook for updating dict objects with items. | Optional[list] |
delete | Hook for getting a key based on a key path which is a list with keys and numbers for indexes in a list. | NoneType |
get | Hook for getting a key based on a key path which is a list with keys and numbers for indexes in a list. | None |
keys | Hook for returning the keys of a dict as a list. | Optional[list] |
pop | Hook for removing (pop ) a key from a dict or item from a list based on index.Follows python's pop |
Union[dict, list, NoneType] |
set | Hook for setting a key based on a key path which is a list with keys and numbers for indexes in a list. | None |
update | Hook for updating dict objects with values, appending list values, or overwriting string / int / float values. | Optional[dict] |
values | Hook for returning the values of a dict as a list. | Optional[list] |
Examples¶
set¶
Set a previous key based on a key path
stuff:
and: things
set_>: set stuff/and other-stuff
stuff:
and: other-stuff
get¶
Get a previous key based on a key path
stuff:
and: things
get->: get stuff/and
stuff:
and: things
get: things
delete¶
Delete a previous key based on a key path
stuff:
and: things
delete_>: delete stuff/and/things
stuff:
and:
pop¶
Removes an item from a list or key from a map in place based or with a result
path:
to:
list:
- stuff
- things
result->: pop {{path.to.list}}
remove in place_>: pop path/to/list 0
path:
to:
list:
- things
result:
- stuff
append¶
Appends an item to a list in place or with a result
list:
- stuff
result->: append {{path.to.list}} things
append in place_>: append path/to/list 0
list:
- stuff
- things
result:
- stuff
- things
keys¶
Get the keys from a dict
path:
to:
map:
stuff: 1
things: 2
map_keys->: keys path/to/map
path:
to:
map:
stuff: things
foo: bar
map_keys:
- stuff
- things