Allow using a dot (``.``) to access attributes of a variable
ClosedPublic

Authored by jskladan on Apr 21 2016, 1:52 PM.

Details

Summary

The formula yaml file uses modified string.Template_ syntax for variables. As in
the standard, you can use `$variable or ${variable}` format, and you need to
make the dollar sign doubled if you want to include it literally (`$$not_a_variable`).

On top of that, you can use a dot (`.`) to access attributes of a variable.
For the sake of convenience, `${foo.bar}` does the following things on the Python layer:

  • check for an item `bar in foo (foo.__getitem__('bar')`)
  • if there is not, check for an attribute `bar in foo (getattr(foo, 'bar')`)
  • if there is not, raises `TaskotronYamlError`

.. code-block:: yaml

actions:
    - name: first step
      directive_one:
          arg1: value1
      export: firststep_output

    - name: second step
      directive_two:
          arg1: ${firststep_output.bar}
Test Plan

Added unittests

Diff Detail

Repository
rLTRN libtaskotron
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
jskladan retitled this revision from to Allow using a dot (``.``) to access attributes of a variable.Apr 21 2016, 1:52 PM
jskladan updated this object.
jskladan edited the test plan for this revision. (Show Details)
jskladan added a reviewer: libtaskotron.
lbrabec accepted this revision.Apr 27 2016, 1:07 PM
lbrabec added a reviewer: lbrabec.
lbrabec added a subscriber: lbrabec.

LGTM, but see T788.

This revision is now accepted and ready to land.Apr 27 2016, 1:09 PM
tflink accepted this revision.Apr 28 2016, 4:55 AM
tflink added a reviewer: tflink.

minor question otherwise looks good

libtaskotron/taskformula.py
22

does this need to be here if it's commented out?

Closed by commit rLTRN6822b1c5a960: Allow using a dot (``.``) to access attributes of a variable (authored by Josef Skladanka <jskladan@redhat.com>). · Explain WhyMay 3 2016, 12:40 PM
This revision was automatically updated to reflect the committed changes.