chiark / gitweb /
Add uppercase STL and HEX to file dialog filters for linux/MacOS
[cura.git] / Cura / fabmetheus_utilities / geometry / statements / statement.py
1 """
2 Polygon path.
3
4 """
5
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.
8 import __init__
9
10 from fabmetheus_utilities.geometry.geometry_utilities import evaluate
11
12
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'
17
18
19 def processElementNode(elementNode):
20         "Process the xml element."
21         functions = elementNode.getXMLProcessor().functions
22         if len(functions) < 1:
23                 print('Warning, there are no functions in processElementNode in statement for:')
24                 print(elementNode)
25                 return
26         function = functions[-1]
27         evaluate.setLocalAttribute(elementNode)
28         if elementNode.xmlObject.value == None:
29                 print('Warning, elementNode.xmlObject.value is None in processElementNode in statement for:')
30                 print(elementNode)
31                 return
32         localValue = evaluate.getEvaluatedExpressionValueBySplitLine(elementNode, elementNode.xmlObject.value)
33         keywords = elementNode.xmlObject.key.split('.')
34         if len(keywords) == 0:
35                 print('Warning, there are no keywords in processElementNode in statement for:')
36                 print(elementNode)
37                 return
38         firstWord = keywords[0]
39         if len(keywords) == 1:
40                 function.localDictionary[firstWord] = localValue
41                 return
42         attributeName = keywords[-1]
43         object = None
44         if firstWord == 'self':
45                 object = function.classObject
46         else:
47                 object = function.localDictionary[firstWord]
48         for keywordIndex in xrange(1, len(keywords) - 1):
49                 object = object._getAccessibleAttribute(keywords[keywordIndex])
50         object._setAccessibleAttribute(attributeName, localValue)