chiark / gitweb /
Add uppercase STL and HEX to file dialog filters for linux/MacOS
[cura.git] / Cura / fabmetheus_utilities / geometry / statements / _print.py
1 """
2 Print statement.
3
4 There is also the print attribute in geometry_utilities/evaluate_fundamentals/print.py
5
6 The model is xml_models/geometry_utilities/evaluate_fundamentals/print.xml
7
8 """
9
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.
12 import __init__
13
14 from fabmetheus_utilities.geometry.geometry_utilities import evaluate
15
16
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'
21
22
23 def getLocalDictionary( attributesKey, elementNode):
24         "Get the local dictionary."
25         xmlProcessor = elementNode.getXMLProcessor()
26         if len( xmlProcessor.functions ) < 1:
27                 return None
28         return xmlProcessor.functions[-1].localDictionary
29
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 ] ) )
43                         return
44         value = elementNode.attributes[attributesKey]
45         evaluatedValue = None
46         if value == '':
47                 evaluatedValue = evaluate.getEvaluatedExpressionValue(elementNode, attributesKey)
48         else:
49                 evaluatedValue = evaluate.getEvaluatedExpressionValue(elementNode, value)
50         print('%s: %s' % ( attributesKey, evaluatedValue ) )
51
52 def processElementNode(elementNode):
53         "Process the xml element."
54         if len(elementNode.getTextContent()) > 1:
55                 print(elementNode.getTextContent())
56                 return
57         attributesKeys = elementNode.attributes.keys()
58         if len( attributesKeys ) < 1:
59                 print('')
60                 return
61         attributesKeys.sort()
62         for attributesKey in attributesKeys:
63                 printAttributesKey( attributesKey, elementNode)