Replace tokens in yaml file python

Viewed 345

I have the following yaml file config.yml:

PATH1: /this/is/the/first/path
PATH2: $PATH1/plus/second/path

I read it in python in this way:

import yaml

with open("../etc/test.yml", "r") as f:
    config = yaml.safe_load(f)
print(config)

and this is obviously what I get when I print config dictionary:

{'PATH2': '$PATH1/plus/second/path', 'PATH1': '/this/is/the/first/path'}

What I would have instead is:

{'PATH2': '/this/is/the/first/path/plus/second/path', 'PATH1': '/this/is/the/first/path'}

Is there any built-in way to achieve this goal? Or I have to create something to replace them on my own?

1 Answers
Related