pypyr.steps.contextcopy permalink

copy values & structures from one part of context to another permalink

Copies context values from already existing context values.

This is handy if you need to prepare certain keys in context where a next step might need a specific key. If you already have the value in context, you can create a new key (or update existing key) with that value.

contextcopy and set overwrite existing keys. If you want to merge new values into an existing destination hierarchy, use contextmerge instead.

So let’s say you already have context[‘currentKey’] = [’eggs’]. If you set newKey: currentKey, you’ll end up with:

currentKey: eggs
newKey: eggs

examples permalink

For example, say your context looks like this,

key1: value1
key2: value2
key3: value3

and your pipeline yaml looks like this:

steps:
  - name: pypyr.steps.contextcopy
    in:
      contextCopy:
        key2: key1
        key4: key3

This will result in context like this:

key1: value1
key2: value1
key3: value3
key4: value3

See a worked example for contextcopy.

see also

last updated on .