nodes.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. #!/usr/bin/env/python
  2. # -*- coding: utf-8 -*-
  3. ###
  4. ### Author: Chris Iatrou (ichrispa@core-vector.net)
  5. ### Version: rev 13
  6. ###
  7. ### This program was created for educational purposes and has been
  8. ### contributed to the open62541 project by the author. All licensing
  9. ### terms for this source is inherited by the terms and conditions
  10. ### specified for by the open62541 project (see the projects readme
  11. ### file for more information on the LGPL terms and restrictions).
  12. ###
  13. ### This program is not meant to be used in a production environment. The
  14. ### author is not liable for any complications arising due to the use of
  15. ### this program.
  16. ###
  17. import sys
  18. import logging
  19. from datatypes import *
  20. logger = logging.getLogger(__name__)
  21. if sys.version_info[0] >= 3:
  22. # strings are already parsed to unicode
  23. def unicode(s):
  24. return s
  25. class Reference(object):
  26. # all either nodeids or strings with an alias
  27. def __init__(self, source, referenceType, target, isForward):
  28. self.source = source
  29. self.referenceType = referenceType
  30. self.target = target
  31. self.isForward = isForward
  32. def __str__(self):
  33. retval = str(self.source)
  34. if not self.isForward:
  35. retval = retval + "<"
  36. retval = retval + "--[" + str(self.referenceType) + "]--"
  37. if self.isForward:
  38. retval = retval + ">"
  39. return retval + str(self.target)
  40. def __repr__(self):
  41. return str(self)
  42. def __eq__(self, other):
  43. return str(self) == str(other)
  44. def __hash__(self):
  45. return hash(str(self))
  46. def RefOrAlias(s):
  47. try:
  48. return NodeId(s)
  49. except Exception:
  50. return s
  51. class Node(object):
  52. def __init__(self):
  53. self.id = NodeId()
  54. self.browseName = QualifiedName()
  55. self.displayName = LocalizedText()
  56. self.description = LocalizedText()
  57. self.symbolicName = String()
  58. self.writeMask = 0
  59. self.userWriteMask = 0
  60. self.references = set()
  61. self.hidden = False
  62. def __str__(self):
  63. return self.__class__.__name__ + "(" + str(self.id) + ")"
  64. def __repr__(self):
  65. return str(self)
  66. def sanitize(self):
  67. pass
  68. def parseXML(self, xmlelement):
  69. for idname in ['NodeId', 'NodeID', 'nodeid']:
  70. if xmlelement.hasAttribute(idname):
  71. self.id = RefOrAlias(xmlelement.getAttribute(idname))
  72. for (at, av) in xmlelement.attributes.items():
  73. if at == "BrowseName":
  74. self.browseName = QualifiedName(av)
  75. elif at == "DisplayName":
  76. self.displayName = LocalizedText(av)
  77. elif at == "Description":
  78. self.description = LocalizedText(av)
  79. elif at == "WriteMask":
  80. self.writeMask = int(av)
  81. elif at == "UserWriteMask":
  82. self.userWriteMask = int(av)
  83. elif at == "EventNotifier":
  84. self.eventNotifier = int(av)
  85. elif at == "SymbolicName":
  86. self.symbolicName = String(av)
  87. for x in xmlelement.childNodes:
  88. if x.nodeType != x.ELEMENT_NODE:
  89. continue
  90. if x.firstChild:
  91. if x.localName == "BrowseName":
  92. self.browseName = QualifiedName(x.firstChild.data)
  93. elif x.localName == "DisplayName":
  94. self.displayName = LocalizedText(x.firstChild.data)
  95. elif x.localName == "Description":
  96. self.description = LocalizedText(x.firstChild.data)
  97. elif x.localName == "WriteMask":
  98. self.writeMask = int(unicode(x.firstChild.data))
  99. elif x.localName == "UserWriteMask":
  100. self.userWriteMask = int(unicode(x.firstChild.data))
  101. if x.localName == "References":
  102. self.parseXMLReferences(x)
  103. def parseXMLReferences(self, xmlelement):
  104. for ref in xmlelement.childNodes:
  105. if ref.nodeType != ref.ELEMENT_NODE:
  106. continue
  107. source = RefOrAlias(str(self.id)) # deep-copy of the nodeid
  108. target = RefOrAlias(ref.firstChild.data)
  109. reftype = None
  110. forward = True
  111. for (at, av) in ref.attributes.items():
  112. if at == "ReferenceType":
  113. reftype = RefOrAlias(av)
  114. elif at == "IsForward":
  115. forward = not "false" in av.lower()
  116. self.references.add(Reference(source, reftype, target, forward))
  117. def popParentRef(self, parentreftypes):
  118. # HasSubtype has precedence
  119. for ref in self.references:
  120. if ref.referenceType == NodeId("ns=0;i=45") and not ref.isForward:
  121. self.references.remove(ref)
  122. return ref
  123. for ref in self.references:
  124. if ref.referenceType in parentreftypes and not ref.isForward:
  125. self.references.remove(ref)
  126. return ref
  127. return Reference(NodeId(), NodeId(), NodeId(), False)
  128. def popTypeDef(self):
  129. for ref in self.references:
  130. if ref.referenceType.i == 40 and ref.isForward:
  131. self.references.remove(ref)
  132. return ref
  133. return Reference(NodeId(), NodeId(), NodeId(), False)
  134. def replaceAliases(self, aliases):
  135. if str(self.id) in aliases:
  136. self.id = NodeId(aliases[self.id])
  137. if isinstance(self, VariableNode) or isinstance(self, VariableTypeNode):
  138. if str(self.dataType) in aliases:
  139. self.dataType = NodeId(aliases[self.dataType])
  140. new_refs = set()
  141. for ref in self.references:
  142. if str(ref.source) in aliases:
  143. ref.source = NodeId(aliases[ref.source])
  144. if str(ref.target) in aliases:
  145. ref.target = NodeId(aliases[ref.target])
  146. if str(ref.referenceType) in aliases:
  147. ref.referenceType = NodeId(aliases[ref.referenceType])
  148. new_refs.add(ref)
  149. self.references = new_refs
  150. def replaceNamespaces(self, nsMapping):
  151. self.id.ns = nsMapping[self.id.ns]
  152. self.browseName.ns = nsMapping[self.browseName.ns]
  153. if hasattr(self, 'dataType') and isinstance(self.dataType, NodeId):
  154. self.dataType.ns = nsMapping[self.dataType.ns]
  155. new_refs = set()
  156. for ref in self.references:
  157. ref.source.ns = nsMapping[ref.source.ns]
  158. ref.target.ns = nsMapping[ref.target.ns]
  159. ref.referenceType.ns = nsMapping[ref.referenceType.ns]
  160. new_refs.add(ref)
  161. self.references = new_refs
  162. class ReferenceTypeNode(Node):
  163. def __init__(self, xmlelement=None):
  164. Node.__init__(self)
  165. self.isAbstract = False
  166. self.symmetric = False
  167. self.inverseName = ""
  168. if xmlelement:
  169. self.parseXML(xmlelement)
  170. def parseXML(self, xmlelement):
  171. Node.parseXML(self, xmlelement)
  172. for (at, av) in xmlelement.attributes.items():
  173. if at == "Symmetric":
  174. self.symmetric = "false" not in av.lower()
  175. elif at == "InverseName":
  176. self.inverseName = str(av)
  177. elif at == "IsAbstract":
  178. self.isAbstract = "false" not in av.lower()
  179. for x in xmlelement.childNodes:
  180. if x.nodeType == x.ELEMENT_NODE:
  181. if x.localName == "InverseName" and x.firstChild:
  182. self.inverseName = str(unicode(x.firstChild.data))
  183. class ObjectNode(Node):
  184. def __init__(self, xmlelement=None):
  185. Node.__init__(self)
  186. self.eventNotifier = 0
  187. if xmlelement:
  188. self.parseXML(xmlelement)
  189. def parseXML(self, xmlelement):
  190. Node.parseXML(self, xmlelement)
  191. for (at, av) in xmlelement.attributes.items():
  192. if at == "EventNotifier":
  193. self.eventNotifier = int(av)
  194. class VariableNode(Node):
  195. def __init__(self, xmlelement=None):
  196. Node.__init__(self)
  197. self.dataType = NodeId()
  198. self.valueRank = -2
  199. self.arrayDimensions = []
  200. # Set access levels to read by default
  201. self.accessLevel = 1
  202. self.userAccessLevel = 1
  203. self.minimumSamplingInterval = 0.0
  204. self.historizing = False
  205. self.value = None
  206. self.xmlValueDef = None
  207. if xmlelement:
  208. self.parseXML(xmlelement)
  209. def parseXML(self, xmlelement):
  210. Node.parseXML(self, xmlelement)
  211. for (at, av) in xmlelement.attributes.items():
  212. if at == "ValueRank":
  213. self.valueRank = int(av)
  214. elif at == "AccessLevel":
  215. self.accessLevel = int(av)
  216. elif at == "UserAccessLevel":
  217. self.userAccessLevel = int(av)
  218. elif at == "MinimumSamplingInterval":
  219. self.minimumSamplingInterval = float(av)
  220. elif at == "DataType":
  221. self.dataType = RefOrAlias(av)
  222. elif at == "ArrayDimensions":
  223. self.arrayDimensions = av.split(",")
  224. for x in xmlelement.childNodes:
  225. if x.nodeType != x.ELEMENT_NODE:
  226. continue
  227. if x.localName == "Value":
  228. self.xmlValueDef = x
  229. elif x.localName == "DataType":
  230. self.dataType = RefOrAlias(av)
  231. elif x.localName == "ValueRank":
  232. self.valueRank = int(unicode(x.firstChild.data))
  233. elif x.localName == "ArrayDimensions" and len(self.arrayDimensions) == 0:
  234. elements = x.getElementsByTagName("ListOfUInt32");
  235. if len(elements):
  236. for idx, v in enumerate(elements[0].getElementsByTagName("UInt32")):
  237. self.arrayDimensions.append(v.firstChild.data)
  238. elif x.localName == "AccessLevel":
  239. self.accessLevel = int(unicode(x.firstChild.data))
  240. elif x.localName == "UserAccessLevel":
  241. self.userAccessLevel = int(unicode(x.firstChild.data))
  242. elif x.localName == "MinimumSamplingInterval":
  243. self.minimumSamplingInterval = float(unicode(x.firstChild.data))
  244. elif x.localName == "Historizing":
  245. self.historizing = "false" not in x.lower()
  246. def allocateValue(self, nodeset):
  247. dataTypeNode = nodeset.getDataTypeNode(self.dataType)
  248. if dataTypeNode is None:
  249. return False
  250. # FIXME: Don't build at all or allocate "defaults"? I'm for not building at all.
  251. if self.xmlValueDef == None:
  252. #logger.warn("Variable " + self.browseName() + "/" + str(self.id()) + " is not initialized. No memory will be allocated.")
  253. return False
  254. self.value = Value()
  255. self.value.parseXMLEncoding(self.xmlValueDef, dataTypeNode, self)
  256. # Array Dimensions must accurately represent the value and will be patched
  257. # reflect the exaxt dimensions attached binary stream.
  258. if not isinstance(self.value, Value) or len(self.value.value) == 0:
  259. self.arrayDimensions = []
  260. return True
  261. class VariableTypeNode(VariableNode):
  262. def __init__(self, xmlelement=None):
  263. VariableNode.__init__(self)
  264. self.isAbstract = False
  265. if xmlelement:
  266. self.parseXML(xmlelement)
  267. def parseXML(self, xmlelement):
  268. Node.parseXML(self, xmlelement)
  269. for (at, av) in xmlelement.attributes.items():
  270. if at == "IsAbstract":
  271. self.isAbstract = "false" not in av.lower()
  272. class MethodNode(Node):
  273. def __init__(self, xmlelement=None):
  274. Node.__init__(self)
  275. self.executable = True
  276. self.userExecutable = True
  277. self.methodDecalaration = None
  278. if xmlelement:
  279. self.parseXML(xmlelement)
  280. def parseXML(self, xmlelement):
  281. Node.parseXML(self, xmlelement)
  282. for (at, av) in xmlelement.attributes.items():
  283. if at == "Executable":
  284. self.executable = "false" not in av.lower()
  285. if at == "UserExecutable":
  286. self.userExecutable = "false" not in av.lower()
  287. if at == "MethodDeclarationId":
  288. self.methodDeclaration = str(av)
  289. class ObjectTypeNode(Node):
  290. def __init__(self, xmlelement=None):
  291. Node.__init__(self)
  292. self.isAbstract = False
  293. if xmlelement:
  294. self.parseXML(xmlelement)
  295. def parseXML(self, xmlelement):
  296. Node.parseXML(self, xmlelement)
  297. for (at, av) in xmlelement.attributes.items():
  298. if at == "IsAbstract":
  299. self.isAbstract = "false" not in av.lower()
  300. class DataTypeNode(Node):
  301. """ DataTypeNode is a subtype of Node describing DataType nodes.
  302. DataType contain definitions and structure information usable for Variables.
  303. The format of this structure is determined by buildEncoding()
  304. Two definition styles are distinguished in XML:
  305. 1) A DataType can be a structure of fields, each field having a name and a type.
  306. The type must be either an encodable builtin node (ex. UInt32) or point to
  307. another DataType node that inherits its encoding from a builtin type using
  308. a inverse "hasSubtype" (hasSuperType) reference.
  309. 2) A DataType may be an enumeration, in which each field has a name and a numeric
  310. value.
  311. The definition is stored as an ordered list of tuples. Depending on which
  312. definition style was used, the __definition__ will hold
  313. 1) A list of ("Fieldname", Node) tuples.
  314. 2) A list of ("Fieldname", int) tuples.
  315. A DataType (and in consequence all Variables using it) shall be deemed not
  316. encodable if any of its fields cannot be traced to an encodable builtin type.
  317. A DataType shall be further deemed not encodable if it contains mixed structure/
  318. enumaration definitions.
  319. If encodable, the encoding can be retrieved using getEncoding().
  320. """
  321. __isEnum__ = False
  322. __xmlDefinition__ = None
  323. __baseTypeEncoding__ = []
  324. __encodable__ = False
  325. __encodingBuilt__ = False
  326. __definition__ = []
  327. def __init__(self, xmlelement=None):
  328. Node.__init__(self)
  329. self.isAbstract = False
  330. self.__xmlDefinition__ = None
  331. self.__baseTypeEncoding__ = []
  332. self.__encodable__ = None
  333. self.__encodingBuilt__ = False
  334. self.__definition__ = []
  335. self.__isEnum__ = False
  336. if xmlelement:
  337. self.parseXML(xmlelement)
  338. def parseXML(self, xmlelement):
  339. Node.parseXML(self, xmlelement)
  340. for (at, av) in xmlelement.attributes.items():
  341. if at == "IsAbstract":
  342. self.isAbstract = "false" not in av.lower()
  343. for x in xmlelement.childNodes:
  344. if x.nodeType == x.ELEMENT_NODE:
  345. if x.localName == "Definition":
  346. self.__xmlDefinition__ = x
  347. def isEncodable(self):
  348. """ Will return True if buildEncoding() was able to determine which builtin
  349. type corresponds to all fields of this DataType.
  350. If no encoding has been build yet, this function will call buildEncoding()
  351. and return True if it succeeds.
  352. """
  353. return self.__encodable__
  354. def getEncoding(self):
  355. """ If the dataType is encodable, getEncoding() returns a nested list
  356. containing the encoding the structure definition for this type.
  357. If no encoding has been build yet, this function will call buildEncoding()
  358. and return the encoding if buildEncoding() succeeds.
  359. If buildEncoding() fails or has failed, an empty list will be returned.
  360. """
  361. if self.__encodable__ == False:
  362. if self.__encodingBuilt__ == False:
  363. return self.buildEncoding()
  364. return []
  365. else:
  366. return self.__baseTypeEncoding__
  367. def buildEncoding(self, nodeset, indent=0, force=False):
  368. """ buildEncoding() determines the structure and aliases used for variables
  369. of this DataType.
  370. The function will parse the XML <Definition> of the dataType and extract
  371. "Name"-"Type" tuples. If successful, buildEncoding will return a nested
  372. list of the following format:
  373. [['Alias1', ['Alias2', ['BuiltinType']]], [Alias2, ['BuiltinType']], ...]
  374. Aliases are fieldnames defined by this DataType or DataTypes referenced. A
  375. list such as ['DataPoint', ['Int32']] indicates that a value will encode
  376. an Int32 with the alias 'DataPoint' such as <DataPoint>12827</DataPoint>.
  377. Only the first Alias of a nested list is considered valid for the BuiltinType.
  378. Single-Elemented lists are always BuiltinTypes. Every nested list must
  379. converge in a builtin type to be encodable. buildEncoding will follow
  380. the first type inheritance reference (hasSupertype) of the dataType if
  381. necessary;
  382. If instead to "DataType" a numeric "Value" attribute is encountered,
  383. the DataType will be considered an enumeration and all Variables using
  384. it will be encoded as Int32.
  385. DataTypes can be either structures or enumeration - mixed definitions will
  386. be unencodable.
  387. Calls to getEncoding() will be iterative. buildEncoding() can be called
  388. only once per dataType, with all following calls returning the predetermined
  389. value. Use of the 'force=True' parameter will force the Definition to be
  390. reparsed.
  391. After parsing, __definition__ holds the field definition as a list. Note
  392. that this might deviate from the encoding, especially if inheritance was
  393. used.
  394. """
  395. prefix = " " + "|"*indent+ "+"
  396. if force==True:
  397. self.__encodingBuilt__ = False
  398. if self.__encodingBuilt__ == True:
  399. if self.isEncodable():
  400. logger.debug(prefix + str(self.__baseTypeEncoding__) + " (already analyzed)")
  401. else:
  402. logger.debug( prefix + str(self.__baseTypeEncoding__) + "(already analyzed, not encodable!)")
  403. return self.__baseTypeEncoding__
  404. self.__encodingBuilt__ = True # signify that we have attempted to built this type
  405. self.__encodable__ = True
  406. if indent==0:
  407. logger.debug("Parsing DataType " + str(self.browseName) + " (" + str(self.id) + ")")
  408. if valueIsInternalType(self.browseName.name):
  409. self.__baseTypeEncoding__ = [self.browseName.name]
  410. self.__encodable__ = True
  411. logger.debug( prefix + str(self.browseName) + "*")
  412. logger.debug("Encodable as: " + str(self.__baseTypeEncoding__))
  413. logger.debug("")
  414. return self.__baseTypeEncoding__
  415. if self.__xmlDefinition__ == None:
  416. # Check if there is a supertype available
  417. for ref in self.references:
  418. if ref.isForward:
  419. continue
  420. # hasSubtype
  421. if ref.referenceType.i == 45:
  422. targetNode = nodeset.nodes[ref.target]
  423. if targetNode is not None and isinstance(targetNode, DataTypeNode):
  424. logger.debug( prefix + "Attempting definition using supertype " + str(targetNode.browseName) + " for DataType " + " " + str(self.browseName))
  425. subenc = targetNode.buildEncoding(nodeset=nodeset, indent=indent+1)
  426. if not targetNode.isEncodable():
  427. self.__encodable__ = False
  428. break
  429. else:
  430. self.__baseTypeEncoding__ = self.__baseTypeEncoding__ + [self.browseName.name, subenc, 0]
  431. if len(self.__baseTypeEncoding__) == 0:
  432. logger.debug(prefix + "No viable definition for " + str(self.browseName) + " " + str(self.id) + " found.")
  433. self.__encodable__ = False
  434. if indent==0:
  435. if not self.__encodable__:
  436. logger.debug("Not encodable (partial): " + str(self.__baseTypeEncoding__))
  437. else:
  438. logger.debug("Encodable as: " + str(self.__baseTypeEncoding__))
  439. logger.debug( "")
  440. return self.__baseTypeEncoding__
  441. isEnum = True
  442. isSubType = True
  443. hasValueRank = 0
  444. # We need to store the definition as ordered data, but can't use orderedDict
  445. # for backward compatibility with Python 2.6 and 3.4
  446. enumDict = []
  447. typeDict = []
  448. # An XML Definition is provided and will be parsed... now
  449. for x in self.__xmlDefinition__.childNodes:
  450. if x.nodeType == x.ELEMENT_NODE:
  451. fname = ""
  452. fdtype = ""
  453. enumVal = ""
  454. valueRank = 0
  455. for at,av in x.attributes.items():
  456. if at == "DataType":
  457. fdtype = str(av)
  458. if fdtype in nodeset.aliases:
  459. fdtype = nodeset.aliases[fdtype]
  460. isEnum = False
  461. elif at == "Name":
  462. fname = str(av)
  463. elif at == "Value":
  464. enumVal = int(av)
  465. isSubType = False
  466. elif at == "ValueRank":
  467. valueRank = int(av)
  468. if valueRank > 0:
  469. logger.warn("Value ranks >0 not fully supported. Further steps may fail")
  470. else:
  471. logger.warn("Unknown Field Attribute " + str(at))
  472. # This can either be an enumeration OR a structure, not both.
  473. # Figure out which of the dictionaries gets the newly read value pair
  474. if isEnum == isSubType:
  475. # This is an error
  476. logger.warn("DataType contains both enumeration and subtype (or neither)")
  477. self.__encodable__ = False
  478. break
  479. elif isEnum:
  480. # This is an enumeration
  481. enumDict.append((fname, enumVal))
  482. continue
  483. else:
  484. if fdtype == "":
  485. # If no datatype given use base datatype
  486. fdtype = "i=24"
  487. # This might be a subtype... follow the node defined as datatype to find out
  488. # what encoding to use
  489. if not NodeId(fdtype) in nodeset.nodes:
  490. raise Exception("Node {} not found in nodeset".format(NodeId(fdtype)))
  491. dtnode = nodeset.nodes[NodeId(fdtype)]
  492. # The node in the datatype element was found. we inherit its encoding,
  493. # but must still ensure that the dtnode is itself validly encodable
  494. typeDict.append([fname, dtnode])
  495. fdtype = str(dtnode.browseName.name)
  496. logger.debug( prefix + fname + " : " + fdtype + " -> " + str(dtnode.id))
  497. subenc = dtnode.buildEncoding(nodeset=nodeset, indent=indent+1)
  498. self.__baseTypeEncoding__ = self.__baseTypeEncoding__ + [[fname, subenc, valueRank]]
  499. if not dtnode.isEncodable():
  500. # If we inherit an encoding from an unencodable not, this node is
  501. # also not encodable
  502. self.__encodable__ = False
  503. break
  504. # If we used inheritance to determine an encoding without alias, there is a
  505. # the possibility that lists got double-nested despite of only one element
  506. # being encoded, such as [['Int32']] or [['alias',['int32']]]. Remove that
  507. # enclosing list.
  508. while len(self.__baseTypeEncoding__) == 1 and isinstance(self.__baseTypeEncoding__[0], list):
  509. self.__baseTypeEncoding__ = self.__baseTypeEncoding__[0]
  510. if isEnum == True:
  511. self.__baseTypeEncoding__ = self.__baseTypeEncoding__ + ['Int32']
  512. self.__definition__ = enumDict
  513. self.__isEnum__ = True
  514. logger.debug( prefix+"Int32* -> enumeration with dictionary " + str(enumDict) + " encodable " + str(self.__encodable__))
  515. return self.__baseTypeEncoding__
  516. if indent==0:
  517. if not self.__encodable__:
  518. logger.debug( "Not encodable (partial): " + str(self.__baseTypeEncoding__))
  519. else:
  520. logger.debug( "Encodable as: " + str(self.__baseTypeEncoding__))
  521. self.__isEnum__ = False
  522. self.__definition__ = typeDict
  523. logger.debug( "")
  524. return self.__baseTypeEncoding__
  525. class ViewNode(Node):
  526. def __init__(self, xmlelement=None):
  527. Node.__init__(self)
  528. self.containsNoLoops == False
  529. self.eventNotifier == False
  530. if xmlelement:
  531. self.parseXML(xmlelement)
  532. def parseXML(self, xmlelement):
  533. Node.parseXML(self, xmlelement)
  534. for (at, av) in xmlelement.attributes.items():
  535. if at == "ContainsNoLoops":
  536. self.containsNoLoops = "false" not in av.lower()
  537. if at == "EventNotifier":
  538. self.eventNotifier = "false" not in av.lower()