pyhocon icon indicating copy to clipboard operation
pyhocon copied to clipboard

Fixup substitutions in included files

Open zapster opened this issue 9 years ago • 1 comments

According to the docs substitutions should be fixed up for included files:

Say for example that the root configuration is this:

{ a : { include "foo.conf" } }

And "foo.conf" might look like this:

{ x : 10, y : ${x} }

If you parsed "foo.conf" in isolation, then ${x} would evaluate to 10, the value at the path x. If you include "foo.conf" in an object at key a, however, then it must be fixed up to be ${a.x} rather than ${x}.

And:

Say that the root configuration redefines a.x, like this:

{
    a : { include "foo.conf" }
    a : { x : 42 }
}

Then the ${x} in "foo.conf", which has been fixed up to ${a.x}, would evaluate to 42 rather than to 10. Substitution happens after parsing the whole configuration.

Currently, this is not supported in pyhocon. I've turned the examples from the docs into tests: https://github.com/zapster/pyhocon/commit/466e298d8168b52515f0fcb7d6d034598cb881c4 (feel free to use them)

zapster avatar Jun 15 '16 13:06 zapster

In pyhocon 0.3.35 this seems to be working. It is evaluated to 42.

macster84 avatar Jan 06 '17 10:01 macster84