Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opcua-asyncio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
opcua-asyncio
Commits
4b85a3f1
Commit
4b85a3f1
authored
Feb 27, 2019
by
oroulet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add default ref type when a parent is specified in XML without ref type
parent
681bcd62
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
23 deletions
+12
-23
asyncua/common/xmlimporter.py
asyncua/common/xmlimporter.py
+6
-20
asyncua/common/xmlparser.py
asyncua/common/xmlparser.py
+6
-3
No files found.
asyncua/common/xmlimporter.py
View file @
4b85a3f1
...
...
@@ -408,37 +408,23 @@ class XmlImporter:
:param nodes: list of NodeDataObjects
:returns: list of sorted nodes
"""
_ndatas
=
list
(
ndatas
)
# list of node ids that are already sorted / inserted
sorted_nodes_ids
=
[]
# list of sorted nodes (i.e. XML Elements)
sorted_ndatas
=
[]
sorted_nodes_ids
=
[]
all_node_ids
=
[
data
.
nodeid
for
data
in
ndatas
]
# list of namespace indexes that are relevant for this import
# we can only respect ordering nodes for namespaces indexes that
# are defined in the xml file itself. Thus we assume that all other
# references namespaces are already known to the server and should
# not create any dependency problems (like "NodeNotFound")
while
len
(
_ndatas
)
>
0
:
pop_nodes
=
[]
for
ndata
in
_ndatas
:
# Insert nodes that
# (1) have no parent / parent_ns is None (e.g. namespace 0)
# (2) ns is not in list of relevant namespaces
while
ndatas
:
for
ndata
in
ndatas
[:]:
if
ndata
.
nodeid
.
NamespaceIndex
not
in
self
.
namespaces
or
\
ndata
.
parent
is
None
or
\
ndata
.
parent
not
in
all_node_ids
:
sorted_ndatas
.
append
(
ndata
)
sorted_nodes_ids
.
append
(
ndata
.
nodeid
)
pop_nodes
.
append
(
ndata
)
ndatas
.
remove
(
ndata
)
else
:
# Check if the nodes parent is already in the list of
# inserted nodes
if
ndata
.
parent
in
sorted_nodes_ids
:
sorted_ndatas
.
append
(
ndata
)
sorted_nodes_ids
.
append
(
ndata
.
nodeid
)
pop_nodes
.
append
(
ndata
)
# Remove inserted nodes from the list
for
ndata
in
pop_nodes
:
_ndatas
.
pop
(
_ndatas
.
index
(
ndata
))
ndatas
.
remove
(
ndata
)
return
sorted_ndatas
asyncua/common/xmlparser.py
View file @
4b85a3f1
...
...
@@ -358,9 +358,12 @@ class XMLParser:
obj
.
typedef
=
ref
.
text
elif
not
struct
.
forward
:
parent
,
parentlink
=
struct
.
target
,
struct
.
reftype
if
obj
.
parent
==
parent
:
if
obj
.
parent
==
parent
or
obj
.
parent
!=
parent
and
not
obj
.
parentlink
:
obj
.
parentlink
=
parentlink
if
not
obj
.
parent
or
not
obj
.
parentlink
:
if
obj
.
parent
and
not
obj
.
parentlink
:
# the case of asimple parent attribute without any reverse link
obj
.
parentlink
=
"HasComponent"
if
not
obj
.
parent
:
obj
.
parent
,
obj
.
parentlink
=
parent
,
parentlink
self
.
logger
.
info
(
"Could not
detect backward reference to
parent for node '%s'"
,
obj
.
nodeid
)
self
.
logger
.
info
(
"Could not
find
parent for node '%s'"
,
obj
.
nodeid
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment