How to use the anyconfig.backend.xml.ET.XML function in anyconfig

To help you get started, we’ve selected a few anyconfig 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 ssato / python-anyconfig / tests / backend / xml.py View on Github external
def test_44__process_children_elems__w_children_have_unique_keys(self):
        (elem, dic, subdic) = (TT.ET.XML("<a>XY</a>"), {}, {})
        TT._process_children_elems(elem, dic, subdic)
        self.assertTrue(dicts_equal(dic, {"a": {"x": "X", "y": "Y"}}))
        self.assertTrue(not subdic)
github ssato / python-anyconfig / tests / backend / xml.py View on Github external
def test_32__process_elem_attrs__w_text(self):
        (elem, dic, subdic) = (TT.ET.XML("<a id="A">AAA</a>"), {}, {})
        TT._process_elem_attrs(elem, dic, subdic)
        self.assertTrue(not dic)
        self.assertTrue(dicts_equal(subdic, {"@attrs": {"id": 'A'}}))
github ssato / python-anyconfig / tests / backend / xml.py View on Github external
def _assert_eq_dic_from_snippet(self, snippet, ref, **opts):
        self.assertEqual(TT.elem_to_container(TT.ET.XML(snippet), **opts), ref)
github ssato / python-anyconfig / tests / backend / xml.py View on Github external
def test_42__process_children_elems__w_attr(self):
        (elem, dic) = (TT.ET.XML("<i>A</i><i>B</i>"), {})
        subdic = {"id": "xyz"}
        ref = subdic.copy()
        ref.update({"#children": [{"i": "A"}, {"i": "B"}]})

        TT._process_children_elems(elem, dic, subdic, children="#children")
        self.assertTrue(not dic)
        self.assertTrue(dicts_equal(subdic, ref), subdic)
github ssato / python-anyconfig / tests / backend / xml.py View on Github external
def test_22__process_elem_text__wo_attrs_and_children_parse(self):
        (elem, dic, subdic) = (TT.ET.XML("<a>A</a>"), {}, {})
        TT._process_elem_text(elem, dic, subdic, text="#text",
                              ac_parse_value=True)
        self.assertTrue(dicts_equal(dic, {"a": 'A'}))
        self.assertTrue(not subdic)

        (elem, dic, subdic) = (TT.ET.XML("<a>1</a>"), {}, {})
        TT._process_elem_text(elem, dic, subdic, text="#text",
                              ac_parse_value=True)
        self.assertTrue(dicts_equal(dic, {"a": 1}))
        self.assertTrue(not subdic)
github ssato / python-anyconfig / tests / backend / xml.py View on Github external
def test_22__process_elem_text__wo_attrs_and_children_parse(self):
        (elem, dic, subdic) = (TT.ET.XML("<a>A</a>"), {}, {})
        TT._process_elem_text(elem, dic, subdic, text="#text",
                              ac_parse_value=True)
        self.assertTrue(dicts_equal(dic, {"a": 'A'}))
        self.assertTrue(not subdic)

        (elem, dic, subdic) = (TT.ET.XML("<a>1</a>"), {}, {})
        TT._process_elem_text(elem, dic, subdic, text="#text",
                              ac_parse_value=True)
        self.assertTrue(dicts_equal(dic, {"a": 1}))
        self.assertTrue(not subdic)
github ssato / python-anyconfig / tests / backend / xml.py View on Github external
def test_46__process_children_elems__w_merge_attrs(self):
        elem = TT.ET.XML("<a z="Z">XY</a>")
        dic = {"a": {"@attrs": {"z": "Z"}}}
        subdic = dic["a"]["@attrs"]
        TT._process_children_elems(elem, dic, subdic, merge_attrs=True)
        self.assertTrue(dicts_equal(dic, {"a": {"x": "X", "y": "Y",
                                                "z": "Z"}}), dic)
github ssato / python-anyconfig / tests / backend / xml.py View on Github external
def test_24__process_elem_text__w_attrs(self):
        (elem, dic, subdic) = (TT.ET.XML("<a id="1">A</a>"), {}, {})
        TT._process_elem_text(elem, dic, subdic, text="#text")
        self.assertTrue(not dic)
        self.assertTrue(dicts_equal(subdic, {"#text": 'A'}))
github ssato / python-anyconfig / tests / backend / xml.py View on Github external
def test_30__process_elem_attrs__wo_text_and_children(self):
        (elem, dic, subdic) = (TT.ET.XML("<a id="A">"), {}, {})
        TT._process_elem_attrs(elem, dic, subdic)
        self.assertTrue(not dic)
        self.assertTrue(dicts_equal(subdic, {"@attrs": {"id": 'A'}}))
</a>