6 from __future__ import absolute_import
7 #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.
10 from fabmetheus_utilities.geometry.geometry_utilities import evaluate
13 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
14 __credits__ = 'Art of Illusion <http://www.artofillusion.org/>'
15 __date__ = '$Date: 2008/02/05 $'
16 __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
19 def processChildNodesByIndexValue( elementNode, function, index, indexValue, value ):
20 "Process childNodes by index value."
21 if indexValue.indexName != '':
22 function.localDictionary[ indexValue.indexName ] = index
23 if indexValue.valueName != '':
24 function.localDictionary[ indexValue.valueName ] = value
25 function.processChildNodes(elementNode)
27 def processElementNode(elementNode):
28 "Process the xml element."
29 if elementNode.xmlObject == None:
30 elementNode.xmlObject = IndexValue(elementNode)
31 if elementNode.xmlObject.inSplitWords == None:
33 xmlProcessor = elementNode.getXMLProcessor()
34 if len( xmlProcessor.functions ) < 1:
35 print('Warning, "for" element is not in a function in processElementNode in for.py for:')
38 function = xmlProcessor.functions[-1]
39 inValue = evaluate.getEvaluatedExpressionValueBySplitLine(elementNode, elementNode.xmlObject.inSplitWords)
40 if inValue.__class__ == list or inValue.__class__ == str:
41 for index, value in enumerate( inValue ):
42 processChildNodesByIndexValue( elementNode, function, index, elementNode.xmlObject, value )
44 if inValue.__class__ == dict:
45 inKeys = inValue.keys()
48 processChildNodesByIndexValue( elementNode, function, inKey, elementNode.xmlObject, inValue[ inKey ] )
52 "Class to get the in attribute, the index name and the value name."
53 def __init__(self, elementNode):
55 self.inSplitWords = None
57 if 'index' in elementNode.attributes:
58 self.indexName = elementNode.attributes['index']
60 if 'value' in elementNode.attributes:
61 self.valueName = elementNode.attributes['value']
62 if 'in' in elementNode.attributes:
63 self.inSplitWords = evaluate.getEvaluatorSplitWords( elementNode.attributes['in'] )
65 print('Warning, could not find the "in" attribute in IndexValue in for.py for:')
68 if len( self.inSplitWords ) < 1:
69 self.inSplitWords = None
70 print('Warning, could not get split words for the "in" attribute in IndexValue in for.py for:')