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
29fc4f64
Commit
29fc4f64
authored
Oct 24, 2016
by
olivier R-D
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pylint of xml code
parent
4ea99310
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
16 deletions
+13
-16
opcua/common/xmlexporter.py
opcua/common/xmlexporter.py
+0
-1
opcua/common/xmlimporter.py
opcua/common/xmlimporter.py
+8
-7
opcua/common/xmlparser.py
opcua/common/xmlparser.py
+5
-8
No files found.
opcua/common/xmlexporter.py
View file @
29fc4f64
...
...
@@ -306,7 +306,6 @@ class XmlExporter(object):
aliases_el
=
Et
.
Element
(
'Aliases'
)
ordered_keys
=
list
(
self
.
aliases
.
keys
())
print
(
"KEYS"
,
ordered_keys
)
ordered_keys
.
sort
()
for
nodeid
in
ordered_keys
:
name
=
self
.
aliases
[
nodeid
]
...
...
opcua/common/xmlimporter.py
View file @
29fc4f64
"""
G
add node defined in XML to address space
"""
add node
s
defined in XML to address space
format is the one from opc-ua specification
"""
import
logging
import
uuid
import
dateutil.parser
from
copy
import
copy
import
dateutil.parser
from
opcua
import
ua
from
opcua.common
import
xmlparser
...
...
@@ -192,17 +193,17 @@ class XmlImporter(object):
res
[
0
].
StatusCode
.
check
()
return
res
[
0
].
AddedNodeId
def
_make_ext_obj
(
se
fl
,
obj
):
def
_make_ext_obj
(
se
lf
,
obj
):
ext
=
getattr
(
ua
,
obj
.
objname
)()
for
name
,
val
in
obj
.
body
:
if
type
(
val
)
is
str
:
if
isinstance
(
val
,
str
)
:
raise
Exception
(
"Error val should a dict"
,
name
,
val
)
else
:
for
attname
,
v
in
val
:
# tow possible values:
# either we get value directly
# or a dict if it s an object or a list
if
type
(
v
)
is
str
:
if
isinstance
(
v
,
str
)
:
setattr
(
ext
,
attname
,
to_python
(
v
,
ext
,
attname
))
else
:
# so we have either an object or a list...
...
...
@@ -229,7 +230,7 @@ class XmlImporter(object):
"""
Returns the value for a Variable based on the objects value type.
"""
self
.
logger
.
debug
(
"Setting value with type %s and value %s"
,
obj
.
valuetype
,
obj
.
value
)
self
.
logger
.
debug
(
"Setting value with type %s and value %s"
,
obj
.
valuetype
,
obj
.
value
)
if
obj
.
valuetype
==
'ListOfExtensionObject'
:
values
=
[]
for
ext
in
obj
.
value
:
...
...
opcua/common/xmlparser.py
View file @
29fc4f64
...
...
@@ -9,10 +9,7 @@ import xml.etree.ElementTree as ET
def
_to_bool
(
val
):
if
val
in
(
"True"
,
"true"
,
"on"
,
"On"
,
"1"
):
return
True
else
:
return
False
return
val
in
(
"True"
,
"true"
,
"on"
,
"On"
,
"1"
)
def
ua_type_to_python
(
val
,
uatype
):
...
...
@@ -22,7 +19,7 @@ def ua_type_to_python(val, uatype):
return
_to_bool
(
val
)
elif
uatype
in
(
"Double"
,
"Float"
):
return
float
(
val
)
elif
uatype
in
(
"String"
)
:
elif
uatype
==
"String"
:
return
val
elif
uatype
in
(
"Bytes"
,
"Bytes"
,
"ByteString"
,
"ByteArray"
):
if
sys
.
version_info
.
major
>
2
:
...
...
@@ -214,7 +211,7 @@ class XMLParser(object):
obj
.
value
=
int
(
child_el
.
text
)
elif
ntag
in
(
"Float"
,
"Double"
):
obj
.
value
=
float
(
child_el
.
text
)
elif
ntag
in
(
"Boolean"
)
:
elif
ntag
==
"Boolean"
:
obj
.
value
=
_to_bool
(
child_el
.
text
)
elif
ntag
in
(
"ByteString"
,
"String"
):
mytext
=
child_el
.
text
...
...
@@ -222,9 +219,9 @@ class XMLParser(object):
mytext
=
""
mytext
=
mytext
.
replace
(
'
\
n
'
,
''
).
replace
(
'
\
r
'
,
''
)
obj
.
value
=
mytext
elif
ntag
in
(
"DateTime"
)
:
elif
ntag
==
"DateTime"
:
obj
.
value
=
child_el
.
text
elif
ntag
in
(
"Guid"
)
:
elif
ntag
==
"Guid"
:
self
.
_parse_value
(
child_el
,
obj
)
obj
.
valuetype
=
obj
.
datatype
# override parsed string type to guid
elif
ntag
==
"LocalizedText"
:
...
...
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