How to use the pyhocon.ConfigParser function in pyhocon

To help you get started, we’ve selected a few pyhocon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chimpler / pyhocon / tests / test_config_parser.py View on Github external
"""
            a : { }
            b : 1
            c : ${a} { d : [ ${b} ] }
            """,
            resolve=False
        )
        config2 = ConfigFactory.parse_string(
            """
            e : ${a} {
            }
            """,
            resolve=False
        )
        merged = ConfigTree.merge_configs(config1, config2)
        resolved = ConfigParser.resolve_substitutions(merged)
        assert resolved.get("c.d") == [1]
github chimpler / pyhocon / tests / test_config_parser.py View on Github external
"""
            a : { }
            b : 1
            c : ${a} { d : [ ${b} ] }
            """,
            resolve=False
        )
        config2 = ConfigFactory.parse_string(
            """
            e : ${a} {
            }
            """,
            resolve=False
        )
        merged = ConfigTree.merge_configs(config1, config2)
        ConfigParser.resolve_substitutions(merged)
        assert merged.get("c.d") == [1]
github chimpler / pyhocon / tests / test_config_parser.py View on Github external
"""
            x : { v1: 1 }
            b1 : {v2: 2 }
            b = [${b1}]
            """,
            resolve=False
        )
        config2 = ConfigFactory.parse_string(
            """
            b2 : ${x} {v2: 3}
            b += [${b2}]
            """,
            resolve=False
        )
        merged = ConfigTree.merge_configs(config1, config2)
        resolved = ConfigParser.resolve_substitutions(merged)
        b = resolved.get("b")
        assert len(b) == 2
        assert b[0] == {'v2': 2}
        assert b[1] == {'v1': 1, 'v2': 3}
github chimpler / pyhocon / tests / test_config_parser.py View on Github external
def test_self_merge_ref_substitutions_object3(self):
        config1 = ConfigFactory.parse_string(
            """
            b1 : { v1: 1 }
            b = [${b1}]
            """,
            resolve=False
        )
        config2 = ConfigFactory.parse_string(
            """
            b1 : { v1: 2, v2: 3 }
            """,
            resolve=False
        )
        merged = ConfigTree.merge_configs(config1, config2)
        ConfigParser.resolve_substitutions(merged)
        assert merged.get("b1") == {"v1": 2, "v2": 3}
        b = merged.get("b")
        assert len(b) == 1
        assert b[0] == {"v1": 2, "v2": 3}
github chimpler / pyhocon / pyhocon / config_tree.py View on Github external
def with_fallback(self, config, resolve=True):
        """
        return a new config with fallback on config
        :param config: config or filename of the config to fallback on
        :param resolve: resolve substitutions
        :return: new config with fallback on config
        """
        if isinstance(config, ConfigTree):
            result = ConfigTree.merge_configs(copy.deepcopy(config), copy.deepcopy(self))
        else:
            from . import ConfigFactory
            result = ConfigTree.merge_configs(ConfigFactory.parse_file(config, resolve=False), copy.deepcopy(self))

        if resolve:
            from . import ConfigParser
            ConfigParser.resolve_substitutions(result)
        return result