nodes.py 25 KB

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