覆盖yaml映射中的变量值

时间:2015-08-14 14:50:43

标签: yaml pyyaml

我在yaml中定义了一个如下所示的映射:

default: &DEFAULT
    bucket: &bucket  default_path
    # Make sure that the second parameter of join doesn't start with a / 
    # otherwise it is interpreted as an absolute path and join won't work
    path1: !!python/object/apply:os.path.join [*bucket, work_area/test1]
    path2: !!python/object/apply:os.path.join [*bucket, work_area/test2]

我需要定义更多的键,其中唯一要覆盖的值是bucket,如:

production:
    <<: *DEFAULT
    bucket: "s3://production-bucket"

但我还是得到了 conf['production']['path1'] =&gt; 'default_path/work_area/test1'
而不是 conf['production']['path1'] => 's3://production-bucket/work_area/test1'
有没有办法在yaml中执行此操作?

从语法中可以明显看出,我使用pyyaml来解析文件。

0 个答案:

没有答案