Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LxmlEventHandler: support lxml Element or Tree as source #531

Merged
merged 1 commit into from
Jun 17, 2021
Merged

Conversation

tefra
Copy link
Owner

@tefra tefra commented Jun 17, 2021

Support parsing from a subtree

import lxml

from xsdata.formats.dataclass.parsers import XmlParser
from xsdata.formats.dataclass.parsers.handlers import LxmlEventHandler

tree = lxml.etree.parse("/tmp/sample.xml")
parser = XmlParser(handler=LxmlEventHandler)
parser.parse(tree.find('.//{some}path'), SomeModel)
  • Support element or tree in the lxml default handler
  • Check if the native python xml has anything similar to lxml iterwalk api
  • Tests

@codecov
Copy link

codecov bot commented Jun 17, 2021

Codecov Report

Merging #531 (eae98a0) into master (5571268) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #531   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           95        95           
  Lines         7662      7664    +2     
  Branches      1325      1326    +1     
=========================================
+ Hits          7662      7664    +2     
Impacted Files Coverage Δ
xsdata/formats/dataclass/parsers/handlers/lxml.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5571268...eae98a0. Read the comment docs.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@tefra
Copy link
Owner Author

tefra commented Jun 17, 2021

For now this is an lxml only feature I am afraid.

@tefra tefra merged commit fb30305 into master Jun 17, 2021
@tefra tefra deleted the feat-530 branch June 17, 2021 21:00
@tefra
Copy link
Owner Author

tefra commented Jun 17, 2021

Resolves #530

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.

1 participant