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
ca0d9f2f
Commit
ca0d9f2f
authored
Mar 10, 2021
by
oroulet
Committed by
oroulet
Mar 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix order or some attributes to exported xml to comply with xsd validator
parent
82b5bf20
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
8 deletions
+4
-8
asyncua/common/xmlexporter.py
asyncua/common/xmlexporter.py
+4
-8
No files found.
asyncua/common/xmlexporter.py
View file @
ca0d9f2f
...
...
@@ -6,9 +6,9 @@ import logging
import
functools
from
collections
import
OrderedDict
import
xml.etree.ElementTree
as
Et
from
copy
import
copy
import
base64
from
dataclasses
import
fields
,
is_dataclass
from
enum
import
Enum
from
asyncua
import
ua
from
asyncua.ua.uatypes
import
type_string_from_type
...
...
@@ -197,6 +197,7 @@ class XmlExporter:
if
desc
not
in
(
None
,
""
):
self
.
_add_sub_el
(
node_el
,
'Description'
,
desc
)
# FIXME: add WriteMask and UserWriteMask
await
self
.
_add_ref_els
(
node_el
,
node
)
return
node_el
async
def
add_etree_object
(
self
,
node
):
...
...
@@ -207,7 +208,6 @@ class XmlExporter:
var
=
await
node
.
read_attribute
(
ua
.
AttributeIds
.
EventNotifier
)
if
var
.
Value
.
Value
!=
0
:
obj_el
.
attrib
[
"EventNotifier"
]
=
str
(
var
.
Value
.
Value
)
await
self
.
_add_ref_els
(
obj_el
,
node
)
async
def
add_etree_object_type
(
self
,
node
):
"""
...
...
@@ -217,7 +217,6 @@ class XmlExporter:
abstract
=
(
await
node
.
read_attribute
(
ua
.
AttributeIds
.
IsAbstract
)).
Value
.
Value
if
abstract
:
obj_el
.
attrib
[
"IsAbstract"
]
=
'true'
await
self
.
_add_ref_els
(
obj_el
,
node
)
async
def
add_variable_common
(
self
,
node
,
el
):
dtype
=
await
node
.
read_data_type
()
...
...
@@ -240,7 +239,6 @@ class XmlExporter:
Add a UA variable element to the XML etree
"""
var_el
=
await
self
.
_add_node_common
(
"UAVariable"
,
node
)
await
self
.
_add_ref_els
(
var_el
,
node
)
await
self
.
add_variable_common
(
node
,
var_el
)
accesslevel
=
(
await
node
.
read_attribute
(
ua
.
AttributeIds
.
AccessLevel
)).
Value
.
Value
...
...
@@ -269,7 +267,6 @@ class XmlExporter:
abstract
=
await
node
.
read_attribute
(
ua
.
AttributeIds
.
IsAbstract
)
if
abstract
.
Value
.
Value
:
var_el
.
attrib
[
"IsAbstract"
]
=
"true"
await
self
.
_add_ref_els
(
var_el
,
node
)
async
def
add_etree_method
(
self
,
node
):
obj_el
=
await
self
.
_add_node_common
(
"UAMethod"
,
node
)
...
...
@@ -279,11 +276,9 @@ class XmlExporter:
var
=
await
node
.
read_attribute
(
ua
.
AttributeIds
.
UserExecutable
)
if
var
.
Value
.
Value
is
False
:
obj_el
.
attrib
[
"UserExecutable"
]
=
"false"
await
self
.
_add_ref_els
(
obj_el
,
node
)
async
def
add_etree_reference_type
(
self
,
obj
):
obj_el
=
await
self
.
_add_node_common
(
"UAReferenceType"
,
obj
)
await
self
.
_add_ref_els
(
obj_el
,
obj
)
var
=
await
obj
.
read_attribute
(
ua
.
AttributeIds
.
InverseName
)
if
var
is
not
None
and
var
.
Value
.
Value
is
not
None
and
var
.
Value
.
Value
.
Text
is
not
None
:
self
.
_add_sub_el
(
obj_el
,
'InverseName'
,
var
.
Value
.
Value
.
Text
)
...
...
@@ -307,7 +302,6 @@ class XmlExporter:
self
.
_enum_fields_to_etree
(
bname
,
sdef_el
,
sdef
)
else
:
self
.
logger
.
warning
(
"Unknown DataTypeSpecification elemnt: %s"
,
sdef
)
await
self
.
_add_ref_els
(
obj_el
,
obj
)
def
_structure_fields_to_etree
(
self
,
bname
,
sdef_el
,
sdef
):
for
field
in
sdef
.
Fields
:
...
...
@@ -386,6 +380,8 @@ class XmlExporter:
if
isinstance
(
val
,
bytes
):
# FIXME: should we also encode this (localized text I guess) using base64??
el
.
text
=
val
.
decode
(
"utf-8"
)
elif
isinstance
(
val
,
Enum
):
el
.
text
=
str
(
val
.
value
)
else
:
if
val
is
not
None
:
el
.
text
=
str
(
val
)
...
...
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