mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 11:10:21 -07:00
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
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:
parent
0dc1d9045b
commit
3a1ad01b1b
6 changed files with 88 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue