We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Allow creation of macros from within tackle files
Proposal Status: wip
Issue Number: 250
Proposal Doc: typed-macros.md
from typing import Callable from tackle import Context KEY_MACROS: list[Callable[[Context, str], dict]] VALUE_MACROS: list[Callable[[Context, str], dict]]
Macro Types
key(context: Context, key: str, value: Any) -> (key: str, value: Any)
value(context: Context, key: str, value: Any) -> (key: str, value: Any)
Macros:
var_hook_macro(args: list) -> list
First arg has
value macro
blocks_macro(context: 'Context')
compact_hook_call_macro(context: 'Context', element: str) -> dict
list_to_var_macro(context: 'Context', element: list) -> dict
function_field_to_parseable_macro(func_dict: dict, context: 'Context', func_name: str) -> dict
Every key:
Check for arrows in last chars
Signifies block / compact / var hooks
value is:
string
dict
block
list
key->: value
key: ->: value
return
assert
import
merge
raise
exit
print
cmd
set
append
pop
delete
update
generate
gen
return->: "{{value}}" return: ->: "{{value}}"
return: # Key doesn't matter as value is the only data exported ->: return value: "{{value}}"
return->: "{{value}}": "{{key}}" return: ->: "{{value}}": "{{key}}"
return: ->: return value: "{{value}}": "{{key}}"
import->: foo/bar import: ->: foo/bar
import->: - foo/bar - foo/bar2
import: ->: import providers: - foo/bar
assert->: foo==bar assert: ->: foo==bar
assert->: - foo==bar - foo==bar2
assert: ->: assert skip_output: true providers: - foo==bar
merge->: foo: bar merge: ->: literal ->: var merge: true input: foo: bar
key: ->: value --a-key foo
key: ->: value a_key: foo
key: ->: if: foo == 'bar' key: value
key: ->: block if: foo == 'bar' key: value
Note: Block hook maps unknown kwargs to items.
items
Macro could alternatively do this:
key: ->: block if: foo == 'bar' items: key: value
input_dict
Old macros didn't only just return a new value but would re-write the input
This is because later in the parsing we use the input dict to grab some data
parse_sub_context from new_hook from ...
If you don't rewrite the input data then you can't access
This call can likely be avoided as I am not sure wtf is happening there
Looks like we can grab the new context to parse from
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Typed Macros
Allow creation of macros from within tackle files
Proposal Status: wip
Issue Number: 250
Proposal Doc: typed-macros.md
Overview
Macro Types
key(context: Context, key: str, value: Any) -> (key: str, value: Any)
value(context: Context, key: str, value: Any) -> (key: str, value: Any)
Macros:
var_hook_macro(args: list) -> list
First arg has
value macro
blocks_macro(context: 'Context')
compact_hook_call_macro(context: 'Context', element: str) -> dict
list_to_var_macro(context: 'Context', element: list) -> dict
function_field_to_parseable_macro(func_dict: dict, context: 'Context', func_name: str) -> dict
Order
Every key:
Check for arrows in last chars
Signifies block / compact / var hooks
value is:
string
dict
block
list
Key Macros
Compact Hook
Special Keys
return
assert
import
merge
raise
exit
print
cmd
set
append
pop
delete
update
generate
gen
return
import
assert
merge
Expand Keys
Block
Macro could alternatively do this:
Issues
input_dict
Old macros didn't only just return a new value but would re-write the input
This is because later in the parsing we use the input dict to grab some data
parse_sub_context from new_hook from ...
If you don't rewrite the input data then you can't access
This call can likely be avoided as I am not sure wtf is happening there
Looks like we can grab the new context to parse from
The text was updated successfully, but these errors were encountered: