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 2928 2008/04/29 22:44:09 knight"
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 not built_value is None:
57 self.built_value = built_value
58
60 return repr(self.value)
61
64
68
69 is_up_to_date = SCons.Node.Node.children_are_up_to_date
70
76
77 - def write(self, built_value):
78 """Set the value of the node."""
79 self.built_value = built_value
80
82 """Return the value. If necessary, the value is built."""
83 self.build()
84 if not hasattr(self, 'built_value'):
85 self.built_value = self.value
86 return self.built_value
87
88 - def get_contents(self):
89 """By the assumption that the node.built_value is a
90 deterministic product of the sources, the contents of a Value
91 are the concatenation of all the contents of its sources. As
92 the value need not be built when get_contents() is called, we
93 cannot use the actual node.built_value."""
94 contents = str(self.value)
95 for kid in self.children(None):
96 contents = contents + kid.get_contents()
97 return contents
98
100 cur_csig = self.get_csig()
101 try:
102 return cur_csig != prev_ni.csig
103 except AttributeError:
104 return 1
105
107 """Because we're a Python value node and don't have a real
108 timestamp, we get to ignore the calculator and just use the
109 value contents."""
110 try:
111 return self.ninfo.csig
112 except AttributeError:
113 pass
114 contents = self.get_contents()
115 self.get_ninfo().csig = contents
116 return contents
117