Commit 29fc4f64 authored by olivier R-D's avatar olivier R-D

pylint of xml code

parent 4ea99310
......@@ -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]
......
"""G
add node defined in XML to address space
"""
add nodes 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(sefl, obj):
def _make_ext_obj(self, 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:
......
......@@ -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":
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment