21 def variable(self, path, namespace='EnvSchema', name=None):
22 '''Returns list containing name of variable, action and value.
24 @param path: a file name or a file-like object
26 If no name given, returns list of lists of all variables and locals(instead of action 'local' is filled).
28 isFilename =
type(path)
is str
31 checksum.update(open(path,
'rb').read())
32 checksum = checksum.digest()
37 oldsum, data = load(f)
38 if oldsum == checksum:
50 doc = minidom.parse(path)
54 ELEMENT_NODE = minidom.Node.ELEMENT_NODE
56 nodes = doc.getElementsByTagNameNS(namespace,
"config")[0].childNodes
60 if node.nodeType == ELEMENT_NODE:
61 action = str(node.localName)
63 if action ==
'include':
65 value = str(node.childNodes[0].data)
68 variables.append((action, (value, caller, str(node.getAttribute(
'hints')))))
70 elif action ==
'search_path':
72 value = str(node.childNodes[0].data)
75 variables.append((action, (value,
None,
None)))
78 varname = str(node.getAttribute(
'variable'))
79 if name
and varname != name:
82 if action ==
'declare':
83 variables.append((action, (varname, str(node.getAttribute(
'type')), str(node.getAttribute(
'local')))))
86 value = str(node.childNodes[0].data)
89 variables.append((action, (varname, value,
None)))
94 dump((checksum, variables), f, protocol=2)