add special word '+value' to add_children/set_children in xml module (#8437)
Some checks failed
EOL CI / EOL Sanity (Ⓐ2.15) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py2.7) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py3.10) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py3.5) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/3/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/3/) (push) Has been cancelled
nox / Run extra sanity tests (push) Has been cancelled

* 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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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