我在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
来解析文件。