nodes.py 25 KB

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