当前位置: 首页>>代码示例>>Python>>正文


Python ConfigTree.put方法代码示例

本文整理汇总了Python中pyhocon.config_tree.ConfigTree.put方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigTree.put方法的具体用法?Python ConfigTree.put怎么用?Python ConfigTree.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyhocon.config_tree.ConfigTree的用法示例。


在下文中一共展示了ConfigTree.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_getter_type_conversion_bool_to_string

# 需要导入模块: from pyhocon.config_tree import ConfigTree [as 别名]
# 或者: from pyhocon.config_tree.ConfigTree import put [as 别名]
    def test_getter_type_conversion_bool_to_string(self):
        config_tree = ConfigTree()
        config_tree.put("bool-true", True)
        assert config_tree.get_string("bool-true") == "true"

        config_tree.put("bool-false", False)
        assert config_tree.get_string("bool-false") == "false"
开发者ID:cnspica,项目名称:pyhocon,代码行数:9,代码来源:test_config_tree.py

示例2: test_config_logging

# 需要导入模块: from pyhocon.config_tree import ConfigTree [as 别名]
# 或者: from pyhocon.config_tree.ConfigTree import put [as 别名]
 def test_config_logging(self):
     import logging.config
     config_tree = ConfigTree()
     config_tree.put('version', 1)
     config_tree.put('root.level', logging.INFO)
     assert dict(config_tree)['version'] == 1
     logging.config.dictConfig(config_tree)
开发者ID:okdtsk,项目名称:pyhocon,代码行数:9,代码来源:test_config_tree.py

示例3: test_getter_type_conversion_number_to_string

# 需要导入模块: from pyhocon.config_tree import ConfigTree [as 别名]
# 或者: from pyhocon.config_tree.ConfigTree import put [as 别名]
    def test_getter_type_conversion_number_to_string(self):
        config_tree = ConfigTree()
        config_tree.put("int", 5)
        assert config_tree.get_string("int") == "5"

        config_tree.put("float", 2.345)
        assert config_tree.get_string("float") == "2.345"
开发者ID:cnspica,项目名称:pyhocon,代码行数:9,代码来源:test_config_tree.py

示例4: test_contains_with_quoted_keys

# 需要导入模块: from pyhocon.config_tree import ConfigTree [as 别名]
# 或者: from pyhocon.config_tree.ConfigTree import put [as 别名]
 def test_contains_with_quoted_keys(self):
     config_tree = ConfigTree()
     config_tree.put('a.b."c.d"', 5)
     assert 'a' in config_tree
     assert 'a.b' in config_tree
     assert 'a.c' not in config_tree
     assert 'a.b."c.d"' in config_tree
     assert 'a.b.c.d' not in config_tree
开发者ID:chimpler,项目名称:pyhocon,代码行数:10,代码来源:test_config_tree.py

示例5: test_contains

# 需要导入模块: from pyhocon.config_tree import ConfigTree [as 别名]
# 或者: from pyhocon.config_tree.ConfigTree import put [as 别名]
 def test_contains(self):
     config_tree = ConfigTree()
     config_tree.put('a.b', 5)
     config_tree.put('a.c', None)
     assert 'a' in config_tree
     assert 'a.b' in config_tree
     assert 'a.c' in config_tree
     assert 'a.b.c' not in config_tree
开发者ID:chimpler,项目名称:pyhocon,代码行数:10,代码来源:test_config_tree.py

示例6: test_numerically_index_objects_to_arrays

# 需要导入模块: from pyhocon.config_tree import ConfigTree [as 别名]
# 或者: from pyhocon.config_tree.ConfigTree import put [as 别名]
    def test_numerically_index_objects_to_arrays(self):
        config_tree = ConfigTree()
        config_tree.put("list.2", "b")
        config_tree.put("list.0", "a")
        assert config_tree.get_list("list") == ["a", "b"]

        config_tree.put("invalid-list.a", "c")
        config_tree.put("invalid-list.b", "d")
        with pytest.raises(ConfigException):
            config_tree.get_list("invalid-list")
开发者ID:chimpler,项目名称:pyhocon,代码行数:12,代码来源:test_config_tree.py

示例7: create_tree

# 需要导入模块: from pyhocon.config_tree import ConfigTree [as 别名]
# 或者: from pyhocon.config_tree.ConfigTree import put [as 别名]
 def create_tree(value):
     if isinstance(value, dict):
         res = ConfigTree(root=root)
         for key, child_value in value.items():
             res.put(key, create_tree(child_value))
         return res
     if isinstance(value, list):
         return [create_tree(v) for v in value]
     else:
         return value
开发者ID:chimpler,项目名称:pyhocon,代码行数:12,代码来源:config_parser.py

示例8: test_config_tree_special_characters

# 需要导入模块: from pyhocon.config_tree import ConfigTree [as 别名]
# 或者: from pyhocon.config_tree.ConfigTree import put [as 别名]
 def test_config_tree_special_characters(self):
     special_characters = '$}[]:=+#`^[email protected]*&.'
     for char in special_characters:
         config_tree = ConfigTree()
         escaped_key = "\"test{char}key\"".format(char=char)
         key = "a.b.{escaped_key}".format(escaped_key=escaped_key)
         config_tree.put(key, "value")
         hocon_tree = HOCONConverter.to_hocon(config_tree)
         assert escaped_key in hocon_tree
         parsed_tree = ConfigFactory.parse_string(hocon_tree)
         assert parsed_tree.get(key) == "value"
开发者ID:chimpler,项目名称:pyhocon,代码行数:13,代码来源:test_config_tree.py

示例9: test_plain_ordered_dict

# 需要导入模块: from pyhocon.config_tree import ConfigTree [as 别名]
# 或者: from pyhocon.config_tree.ConfigTree import put [as 别名]
 def test_plain_ordered_dict(self):
     config_tree = ConfigTree()
     config_tree.put('"a.b"', 5)
     config_tree.put('a."b.c"', [ConfigTree(), 2])
     config_tree.get('a."b.c"')[0].put('"c.d"', 1)
     d = OrderedDict()
     d['a.b'] = 5
     d['a'] = OrderedDict()
     d['a']['b.c'] = [OrderedDict(), 2]
     d['a']['b.c'][0]['c.d'] = 1
     assert config_tree.as_plain_ordered_dict() == d
开发者ID:ryban,项目名称:pyhocon,代码行数:13,代码来源:test_config_tree.py

示例10: test_config_tree_quoted_string

# 需要导入模块: from pyhocon.config_tree import ConfigTree [as 别名]
# 或者: from pyhocon.config_tree.ConfigTree import put [as 别名]
    def test_config_tree_quoted_string(self):
        config_tree = ConfigTree()
        config_tree.put("a.b.c", "value")
        assert config_tree.get("a.b.c") == "value"

        with pytest.raises(ConfigMissingException):
            assert config_tree.get("a.b.d")

        with pytest.raises(ConfigMissingException):
            config_tree.get("a.d.e")

        with pytest.raises(ConfigWrongTypeException):
            config_tree.get("a.b.c.e")
开发者ID:txominpelu,项目名称:pyhocon,代码行数:15,代码来源:test_config_tree.py

示例11: test_durations

# 需要导入模块: from pyhocon.config_tree import ConfigTree [as 别名]
# 或者: from pyhocon.config_tree.ConfigTree import put [as 别名]
 def test_durations(self):
     one_sec = ("1s", "1 s", "1seconds", "1 seconds", "   1s    ", "   1    s   ",
                "1second",
                "1000", "1000ms", "1000 ms", "1000   milliseconds", "   1000       milliseconds    ",
                "1000millisecond",
                "1000000us", "1000000   us", "1000000 microseconds", "1000000microsecond",
                "1000000000ns", "1000000000 ns", "1000000000  nanoseconds", "1000000000nanosecond",
                "0.01666666666666666666666m", "0.01666666666666666666666 minutes", "0.01666666666666666666666 minute",
                "0.00027777777777777777777h", "0.00027777777777777777777 hours", "0.00027777777777777777777hour",
                "1.1574074074074073e-05d", "1.1574074074074073e-05  days", "1.1574074074074073e-05day")
     config_tree = ConfigTree()
     nanos_in_one_sec = 1000**3
     millis_in_one_sec = 1000
     for repr in one_sec:
         config_tree.put("one_sec", repr)
         assert config_tree.get_nanoseconds() == nanos_in_one_sec
         assert config_tree.get_milliseconds() == millis_in_one_sec
开发者ID:cmenguy,项目名称:pyhocon,代码行数:19,代码来源:test_config_tree.py

示例12: postParse

# 需要导入模块: from pyhocon.config_tree import ConfigTree [as 别名]
# 或者: from pyhocon.config_tree.ConfigTree import put [as 别名]
    def postParse(self, instring, loc, token_list):
        """Create ConfigTree from tokens

        :param instring:
        :param loc:
        :param token_list:
        :return:
        """
        config_tree = ConfigTree()
        for element in token_list:
            expanded_tokens = element.tokens if isinstance(element, ConfigInclude) else [element]

            for tokens in expanded_tokens:
                # key, value1 (optional), ...
                key = tokens[0].strip()
                values = tokens[1:]

                # empty string
                if len(values) == 0:
                    config_tree.put(key, "")
                else:
                    value = values[0]
                    if isinstance(value, list):
                        config_tree.put(key, value, False)
                    else:
                        # Merge dict
                        if isinstance(value, ConfigValues):
                            conf_value = value
                            value.parent = config_tree
                            value.key = key
                        else:
                            conf_value = value
                        config_tree.put(key, conf_value)
        return config_tree
开发者ID:peoplepattern,项目名称:pyhocon,代码行数:36,代码来源:__init__.py

示例13: test_config_list

# 需要导入模块: from pyhocon.config_tree import ConfigTree [as 别名]
# 或者: from pyhocon.config_tree.ConfigTree import put [as 别名]
    def test_config_list(self):
        config_tree = ConfigTree()

        config_tree.put("a.b.c", [4, 5])
        assert config_tree.get("a.b.c") == [4, 5]

        config_tree.put("a.b.c", [6, 7])
        assert config_tree.get("a.b.c") == [6, 7]

        config_tree.put("a.b.c", [8, 9], True)
        assert config_tree.get("a.b.c") == [6, 7, 8, 9]
开发者ID:ryban,项目名称:pyhocon,代码行数:13,代码来源:test_config_tree.py

示例14: postParse

# 需要导入模块: from pyhocon.config_tree import ConfigTree [as 别名]
# 或者: from pyhocon.config_tree.ConfigTree import put [as 别名]
    def postParse(self, instring, loc, token_list):
        """Create ConfigTree from tokens

        :param instring:
        :param loc:
        :param token_list:
        :return:
        """
        config_tree = ConfigTree()
        for element in token_list:
            # from include then merge items
            expanded_tokens = element.items() if isinstance(element, ConfigTree) else [element]

            for tokens in expanded_tokens:
                # key, value1, value2, ...
                key = tokens[0].strip()
                values = tokens[1:]

                # empty string
                if len(values) == 0:
                    config_tree.put(key, '')
                else:
                    if isinstance(values[0], list):
                        # Merge arrays
                        config_tree.put(key, values[0], False)
                        for value in values[1:]:
                            config_tree.put(key, value, True)
                    else:
                        # Merge dict
                        for value in values:
                            if isinstance(value, ConfigList):
                                conf_value = list(value)
                            elif isinstance(value, ConfigValues):
                                conf_value = value
                                value.parent = config_tree
                                value.key = key
                            else:
                                conf_value = value
                            config_tree.put(key, conf_value)

        return config_tree
开发者ID:laserson,项目名称:pyhocon,代码行数:43,代码来源:__init__.py

示例15: test_getter_type_conversion_string_to_bool

# 需要导入模块: from pyhocon.config_tree import ConfigTree [as 别名]
# 或者: from pyhocon.config_tree.ConfigTree import put [as 别名]
    def test_getter_type_conversion_string_to_bool(self):
        config_tree = ConfigTree()
        config_tree.put("bool-string-true", "true")
        assert config_tree.get_bool("bool-string-true") is True

        config_tree.put("bool-string-false", "false")
        assert config_tree.get_bool("bool-string-false") is False

        config_tree.put("bool-string-yes", "yes")
        assert config_tree.get_bool("bool-string-yes") is True

        config_tree.put("bool-string-no", "no")
        assert config_tree.get_bool("bool-string-no") is False

        config_tree.put("bool-string-on", "on")
        assert config_tree.get_bool("bool-string-on") is True

        config_tree.put("bool-string-off", "off")
        assert config_tree.get_bool("bool-string-off") is False

        config_tree.put("invalid-bool-string", "invalid")
        with pytest.raises(ConfigException):
            config_tree.get_bool("invalid-bool-string")
开发者ID:cnspica,项目名称:pyhocon,代码行数:25,代码来源:test_config_tree.py


注:本文中的pyhocon.config_tree.ConfigTree.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。