4 There is also the print attribute in geometry_utilities/evaluate_fundamentals/print.py
6 The model is xml_models/geometry_utilities/evaluate_fundamentals/print.xml
10 from __future__ import absolute_import
11 #Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
14 from fabmetheus_utilities.geometry.geometry_utilities import evaluate
17 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
18 __credits__ = 'Art of Illusion <http://www.artofillusion.org/>'
19 __date__ = '$Date: 2008/02/05 $'
20 __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
23 def getLocalDictionary( attributesKey, elementNode):
24 "Get the local dictionary."
25 xmlProcessor = elementNode.getXMLProcessor()
26 if len( xmlProcessor.functions ) < 1:
28 return xmlProcessor.functions[-1].localDictionary
30 def printAttributesKey( attributesKey, elementNode):
31 "Print the attributesKey."
32 if attributesKey.lower() == '_localdictionary':
33 localDictionary = getLocalDictionary( attributesKey, elementNode)
34 if localDictionary != None:
35 localDictionaryKeys = localDictionary.keys()
36 attributeValue = elementNode.attributes[attributesKey]
37 if attributeValue != '':
38 attributeValue = ' - ' + attributeValue
39 print('Local Dictionary Variables' + attributeValue )
40 localDictionaryKeys.sort()
41 for localDictionaryKey in localDictionaryKeys:
42 print('%s: %s' % ( localDictionaryKey, localDictionary[ localDictionaryKey ] ) )
44 value = elementNode.attributes[attributesKey]
47 evaluatedValue = evaluate.getEvaluatedExpressionValue(elementNode, attributesKey)
49 evaluatedValue = evaluate.getEvaluatedExpressionValue(elementNode, value)
50 print('%s: %s' % ( attributesKey, evaluatedValue ) )
52 def processElementNode(elementNode):
53 "Process the xml element."
54 if len(elementNode.getTextContent()) > 1:
55 print(elementNode.getTextContent())
57 attributesKeys = elementNode.attributes.keys()
58 if len( attributesKeys ) < 1:
62 for attributesKey in attributesKeys:
63 printAttributesKey( attributesKey, elementNode)