Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into topic/self-reference
Browse files Browse the repository at this point in the history
  • Loading branch information
gilles-duboscq committed May 4, 2016
2 parents f867c28 + 2411739 commit c692045
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

* Implemented self-referential subsitutions

# Version 0.3.25

* ConfigValue.transform: do not wrap lists. PR [#76]

# Version 0.3.24

* Use recursive merging when concatenating objects. PR [#74]
Expand Down
4 changes: 2 additions & 2 deletions pyhocon/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def _do_substitute(substitution, resolved_value, is_optional_resolved=True):
if transformation is None and not is_optional_resolved:
result = config_values.overriden_value
else:
result = transformation[0] if isinstance(transformation, list) else transformation
result = transformation

if result is None:
del config_values.parent[config_values.key]
Expand Down Expand Up @@ -453,7 +453,7 @@ def __init__(self, expr=None):

def postParse(self, instring, loc, token_list):
config_values = ConfigValues(token_list, instring, loc)
return config_values.transform()
return [config_values.transform()]


class ConfigTreeParser(TokenConverter):
Expand Down
2 changes: 1 addition & 1 deletion pyhocon/config_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def format_str(v):
main_index += 1
sublist_result.append(token)
result.extend(sublist_result)
return [result]
return result
else:
if len(tokens) == 1:
return tokens[0]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def run_tests(self):

setup(
name='pyhocon',
version='0.3.24',
version='0.3.25',
description='HOCON parser for Python',
long_description='pyhocon is a HOCON parser for Python. Additionally we provide a tool (pyhocon) to convert any HOCON '
'content into json, yaml and properties format.',
Expand Down
18 changes: 18 additions & 0 deletions tests/test_config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1671,3 +1671,21 @@ def test_object_concat(self):
assert config.get_int('o1.foo.c', default=42) == 42
assert config.get_int('o3.foo.a') == 1
assert config.get_int('o3.foo.c') == 4

def test_issue_75(self):
config = ConfigFactory.parse_string(
"""base : {
bar: ["a"]
}
sub : ${base} {
baz: ${base.bar} ["b"]
}
sub2: ${sub}
"""
)

assert config.get_list('base.bar') == ["a"]
assert config.get_list('sub.baz') == ["a", "b"]
assert config.get_list('sub2.baz') == ["a", "b"]

0 comments on commit c692045

Please sign in to comment.