26 def variable(self, path, namespace='EnvSchema', name=None):
27 '''Returns list containing name of variable, action and value.
29 @param path: a file name or a file-like object
31 If no name given, returns list of lists of all variables and locals(instead of action 'local' is filled).
33 isFilename =
type(path)
is str
36 checksum.update(open(path,
'rb').read())
37 checksum = checksum.digest()
42 oldsum, data = load(f)
43 if oldsum == checksum:
55 doc = minidom.parse(path)
59 ELEMENT_NODE = minidom.Node.ELEMENT_NODE
61 nodes = doc.getElementsByTagNameNS(namespace,
"config")[0].childNodes
65 if node.nodeType == ELEMENT_NODE:
66 action = str(node.localName)
68 if action ==
'include':
70 value = str(node.childNodes[0].data)
73 variables.append((action, (value, caller, str(node.getAttribute(
'hints')))))
76 varname = str(node.getAttribute(
'variable'))
77 if name
and varname != name:
80 if action ==
'declare':
81 variables.append((action, (varname, str(node.getAttribute(
'type')), str(node.getAttribute(
'local')))))
84 value = str(node.childNodes[0].data)
87 variables.append((action, (varname, value,
None)))
92 dump((checksum, variables), f, protocol=2)