def get_value(self, vid, attribute={}, resolved=True,subgroup=None): """ get a value for entry with id attribute vid. or from the values field if the attribute argument is provided and matches """ val = None if (type(vid) != type(str())): node = vid vid = node.attrib["id"] else: nodes = self.get_node("entry", {"id":vid}) if (len(nodes) == 0): val = GenericXML.get_value(self, vid, resolved) return val else: node = nodes[0] if (attribute): valnodes = self.get_node("value", attribute,root=node) if (valnodes is not None and len(valnodes) == 1): val = valnodes[0].text elif (node.get("value") is not None): val = node.get("value") else: val = self.set_default_value(vid) if (val is None): # if all else fails val = GenericXML.get_value(self,vid,resolved) if (resolved): val = self.get_resolved_value(val) return val
def __init__(self, caseroot, infile="env_mach_specific.xml"): """ initialize an object interface to file env_mach_specific.xml in the case directory """ if(os.path.isabs(infile)): fullpath = infile else: fullpath = os.path.join(caseroot,infile) GenericXML.__init__(self, fullpath)
def __init__(self,infile): """ initialize an object """ GenericXML.__init__(self,infile) self._testnodes = {} if(os.path.isfile(infile)): testnodes = self.get_node('test') for node in testnodes: self._testnodes[node.attrib["name"]] = node else: self.root.set('version',_VERSION)
def get_value(self, name, resolved=True): """ Get Value of fields in the config_machines.xml file """ expect(self.machine is not None, "Machine object has no machine defined") value = None # COMPILER and MPILIB are special, if called without arguments they get the default value from the # COMPILERS and MPILIBS lists in the file. if (name == "COMPILER"): value = self.get_default_compiler() elif (name == "MPILIB"): value = self.get_default_MPIlib() else: nodes = self.get_node(name, root=self.machine) if (nodes): node = nodes[0] expect(node is not None, "No match found for %s in machine %s" % (name, self.name)) value = node.text if (value is None): # if all else fails value = GenericXML.get_value(self, name) if (resolved): value = self.get_resolved_value(value) return value
def __init__(self, infile=None, files=None, machine=None): """ initialize an object if a filename is provided it will be used, otherwise if a files object is provided it will be used otherwise create a files object from default values """ self.machine = None self.name = None if (infile is None): if (files is None): files = Files() infile = files.get_value("MACHINES_SPEC_FILE") GenericXML.__init__(self, infile) if (machine is None): machine = self.probe_machine_name() self.set_machine(machine)
def get_node(self, nodename, attributes=None, root=None): if (self.machine is not None and root is None and nodename is not "machine"): node = GenericXML.get_node(self, nodename, attributes, root=self.machine) else: node = GenericXML.get_node(self, nodename, attributes, root) return node
def __init__(self, infile=None): GenericXML.__init__(self, infile) self.groups={}
def __init__(self,infile): """ initialize an object """ GenericXML.__init__(self,infile)