eta.util.tt.parse.readrules

readrules(packet)[source]

Create a choice tree from a packet of pattern and template rules.

Parameters:

packet (list[str]) –

A list of form [depth, pattern, optional-pair, depth, pattern, optional-pair, ...], where:

  • depth is 1 for top-level rules, 2 for direct children, etc.,

  • pattern is a decomposition pattern or other output,

  • optional-pair is present iff pattern is a reassembly pattern or other output, and consists of a (latency, directive) tuple, where latency is an integer >= 0 specifying how long to wait to use a rule again, and directive is a symbol such as :out, :subtree, :gist, etc. specifying how the output should be used.

Returns:

root – The root of the choice tree (a nested dict structure) created from the packet.

Return type:

dict