23 def variable(self, path, namespace='EnvSchema', name=None):
24 '''Returns list containing name of variable, action and value.
26 @param path: a file name or a file-like object
28 If no name given, returns list of lists of all variables and locals(instead of action 'local' is filled).
30 isFilename =
type(path)
is str
33 checksum.update(open(path,
'rb').read())
34 checksum = checksum.digest()
39 oldsum, data = load(f)
40 if oldsum == checksum:
53 doc = minidom.parse(path)
54 except ExpatError, exc:
55 self.log.fatal(
'Failed to parse %s: %s', path, exc)
56 self.log.fatal(list(open(path))[exc.lineno-1].rstrip())
57 self.log.fatal(
' ' * exc.offset +
'^')
63 ELEMENT_NODE = minidom.Node.ELEMENT_NODE
65 nodes = doc.getElementsByTagNameNS(namespace,
"config")[0].childNodes
69 if node.nodeType == ELEMENT_NODE:
70 action = str(node.localName)
72 if action ==
'include':
74 value = str(node.childNodes[0].data)
77 variables.append((action, (value, caller, str(node.getAttribute(
'hints')))))
79 elif action ==
'search_path':
81 value = str(node.childNodes[0].data)
84 variables.append((action, (value,
None,
None)))
87 varname = str(node.getAttribute(
'variable'))
88 if name
and varname != name:
91 if action ==
'declare':
92 variables.append((action, (varname, str(node.getAttribute(
'type')), str(node.getAttribute(
'local')))))
95 value = str(node.childNodes[0].data)
98 variables.append((action, (varname, value,
None)))
102 f = open(cpath,
'wb')
103 dump((checksum, variables), f, protocol=2)