add special word '+value' to add_children/set_children in xml module (#8437)

* add special word '_value' to add_children/set_children in xml module

* changelog fragment added

* Update changelogs/fragments/8437-xml-children-value.yml

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>

* rebase

* add integration test

* fix result file of integration test

---------

Co-authored-by: z1kk0 <anamleev@phoenixit.ru>
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
z1kk0
2025-05-31 17:42:24 +03:00
committed by GitHub
parent 0dc1d9045b
commit 3a1ad01b1b
6 changed files with 88 additions and 1 deletions

View File

@@ -301,7 +301,9 @@ EXAMPLES = r"""
# Attributes
name: Scumm bar
location: Monkey island
# Subnodes
# Value
+value: unreal
# Subnodes
_:
- floor: Pirate hall
- floor: Grog storage
@@ -756,6 +758,7 @@ def child_to_element(module, child, in_type):
(key, value) = next(iteritems(child))
if isinstance(value, MutableMapping):
children = value.pop('_', None)
child_value = value.pop('+value', None)
node = etree.Element(key, value)
@@ -765,6 +768,9 @@ def child_to_element(module, child, in_type):
subnodes = children_to_nodes(module, children)
node.extend(subnodes)
if child_value is not None:
node.text = child_value
else:
node = etree.Element(key)
node.text = value