Skip to content

Remove xmltodict and replace with Python's built-in xml ElementTree - #190

Open
andrewhughes101 wants to merge 1 commit into
mainfrom
xmltodict-removal
Open

andrewhughes101 wants to merge 1 commit into
mainfrom
xmltodict-removal

Conversation

@andrewhughes101

@andrewhughes101 andrewhughes101 commented Dec 15, 2025 •

Copy link
Copy Markdown
Collaborator

Built off the other PR to add arch and dev guide docs

Needs some unit testing around the new util explicitly but (Added unit tests) works nicely with existing ones and integration tests pass locally 🎉

@andrewhughes101
andrewhughes101 force-pushed the xmltodict-removal branch 2 times, most recently from 4188759 to 0092770 Compare December 15, 2025 18:40
@andrewhughes101
andrewhughes101 marked this pull request as ready for review December 15, 2025 18:41
Comment on lines 178 to 180
# Xmltodict parses inner error types as Dicts when there is only one item in
# it even though it may well be a list if multiple results were returned. If
# we find a dict here, wrap it in a list so we can account for only one

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably need to change this comment too

Comment thread plugins/module_utils/cmci.py
version="3.0" connect_version="0610">
<resultsummary api_response1="1024" api_response2="0" api_response1_alt="OK" api_response2_alt="" recordcount="4" displayed_recordcount="4"/>
<records>
<cicslocalfile _keydata="BLAH" accessmethod="VSAM" add="ADDABLE" addcnt="0" basdefinever="0" basedsname="DFHCSD" blockformat="BLOCKED"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to have 4 records, to match recordcount, or maybe make it 2 so we can test working with more than one?

Comment on lines +99 to +102
if text:
result['#text'] = text if result else None
return OrderedDict([(tag, result if result else text)])
return OrderedDict([(tag, result if result else None)])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would an if result start make this a bit easier to read?

Suggested change
if text:
result['#text'] = text if result else None
return OrderedDict([(tag, result if result else text)])
return OrderedDict([(tag, result if result else None)])
if result:
result['#text'] = text if text else None
return OrderedDict([(tag, result)])
if text:
return OrderedDict([(tag, text)])
return OrderedDict([(tag, None)])

Comment thread plugins/module_utils/_xml_utils.py
Comment thread plugins/module_utils/_xml_utils.py

@ledina ledina left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Drew, looking good. A few comments, many thanks

Comment thread plugins/module_utils/_xml_utils.py

@AndrewTwydell AndrewTwydell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this import needs updating, but I've run tests and installed / run manually and CMCI modules work as expected.


__metaclass__ = type

from typing import OrderedDict

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from typing import OrderedDict
from collections import OrderedDict

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants