1 """scons.Node.Python
2
3 Python nodes.
4
5 """
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 __revision__ = "src/engine/SCons/Node/Python.py 2014/09/27 12:51:43 garyo"
31
32 import SCons.Node
33
41
44
45 -class Value(SCons.Node.Node):
46 """A class for Python variables, typically passed on the command line
47 or generated by a script, but not from a file or some other source.
48 """
49
50 NodeInfo = ValueNodeInfo
51 BuildInfo = ValueBuildInfo
52
53 - def __init__(self, value, built_value=None):
54 SCons.Node.Node.__init__(self)
55 self.value = value
56 if built_value is not None:
57 self.built_value = built_value
58
60 return repr(self.value)
61
63 return str(self.value)
64
67
71
72 is_up_to_date = SCons.Node.Node.children_are_up_to_date
73
79
80 - def write(self, built_value):
81 """Set the value of the node."""
82 self.built_value = built_value
83
85 """Return the value. If necessary, the value is built."""
86 self.build()
87 if not hasattr(self, 'built_value'):
88 self.built_value = self.value
89 return self.built_value
90
92 """By the assumption that the node.built_value is a
93 deterministic product of the sources, the contents of a Value
94 are the concatenation of all the contents of its sources. As
95 the value need not be built when get_contents() is called, we
96 cannot use the actual node.built_value."""
97
98 contents = str(self.value)
99 for kid in self.children(None):
100 contents = contents + kid.get_contents()
101 return contents
102
103 get_contents = get_text_contents
104
106 cur_csig = self.get_csig()
107 try:
108 return cur_csig != prev_ni.csig
109 except AttributeError:
110 return 1
111
113 """Because we're a Python value node and don't have a real
114 timestamp, we get to ignore the calculator and just use the
115 value contents."""
116 try:
117 return self.ninfo.csig
118 except AttributeError:
119 pass
120 contents = self.get_contents()
121 self.get_ninfo().csig = contents
122 return contents
123
124
125
126
127
128
129