Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CaosDB Crawler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Crawler
Commits
0694462d
Commit
0694462d
authored
7 months ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
ENH: added a new structure element for xml attributes
parent
a6b41c7a
No related branches found
No related tags found
2 merge requests
!181
Release 0.9.0
,
!174
XML Converter
Pipeline
#54288
failed
7 months ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caoscrawler/structure_elements.py
+30
-5
30 additions, 5 deletions
src/caoscrawler/structure_elements.py
with
30 additions
and
5 deletions
src/caoscrawler/structure_elements.py
+
30
−
5
View file @
0694462d
...
...
@@ -175,9 +175,11 @@ class XMLTagElement(StructureElement):
Stores elements of an XML tree.
"""
def
__init__
(
self
,
name
:
str
,
element
:
lxml
.
etree
.
Element
):
super
().
__init__
(
name
)
def
__init__
(
self
,
element
:
lxml
.
etree
.
Element
,
tree
:
lxml
.
etree
.
ElementTree
):
super
().
__init__
(
tree
.
getelementpath
(
element
))
self
.
tag
=
element
self
.
tree
=
tree
class
XMLTextNode
(
StructureElement
):
...
...
@@ -185,7 +187,8 @@ class XMLTextNode(StructureElement):
Stores text nodes of XML trees.
"""
def
__init__
(
self
,
name
:
str
,
value
:
str
):
def
__init__
(
self
,
element
:
lxml
.
etree
.
Element
,
tree
:
lxml
.
etree
.
ElementTree
):
"""
Initializes this XML text node.
...
...
@@ -196,5 +199,27 @@ class XMLTextNode(StructureElement):
- XMLTextNodes just have a text and the name is just for identifying the structure element.
They can only be matched using the match entry in the XMLTextNodeConverter.
"""
super
().
__init__
(
name
)
self
.
value
=
value
super
().
__init__
(
tree
.
getelementpath
(
element
))
self
.
tag
=
element
self
.
value
=
element
.
text
class
XMLAttributeNode
(
StructureElement
):
"""
Stores text nodes of XML trees.
"""
def
__init__
(
self
,
element
:
lxml
.
etree
.
Element
,
key
:
str
,
tree
:
lxml
.
etree
.
ElementTree
):
"""
Initializes this XML attribute node.
element: The xml tree element containing the attribute.
key: The key which identifies the attribute in the list of attributes.
tree: The tree containing the element which is used to set the node path.
"""
super
().
__init__
(
tree
.
getelementpath
(
element
))
self
.
value
=
element
.
attrib
[
key
]
self
.
key
=
key
self
.
tag
=
element
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment