def clone_from_xml(self, node): if (node.nodeType != node.ELEMENT_NODE or node.nodeName != self.name): raise utils.MuddleBug( "Invalid outer element for %s user instruction - %s"%(self.name, node)) new_spec = None new_user = None new_group = None for c in node.childNodes: if (c.nodeType == c.ELEMENT_NODE): if (c.nodeName == filespec.proto.outer_elem_name()): new_spec = filespec.proto.clone_from_xml(c) elif (c.nodeName == "user"): new_user = utils.text_in_node(c) elif (c.nodeName == "group"): new_group = utils.text_in_node(c) else: raise utils.MuddleBug("Invalid element in %s instruction: %s"%(self.name, c.nodeName)) if (new_spec is None) or ((new_user is None) and (new_group is None)): raise utils.MuddleBug("Either user/group or filespec is not specified in XML.") return ChangeUserInstruction(new_spec, new_user, new_group, self.name)
def clone_from_xml(self, node): if (node.nodeType != node.ELEMENT_NODE or node.nodeName != self.name): raise utils.MuddleBug( "Invalid outer element for %s user instruction - %s" % (self.name, node)) new_spec = None new_user = None new_group = None for c in node.childNodes: if (c.nodeType == c.ELEMENT_NODE): if (c.nodeName == filespec.proto.outer_elem_name()): new_spec = filespec.proto.clone_from_xml(c) elif (c.nodeName == "user"): new_user = utils.text_in_node(c) elif (c.nodeName == "group"): new_group = utils.text_in_node(c) else: raise utils.MuddleBug( "Invalid element in %s instruction: %s" % (self.name, c.nodeName)) if (new_spec is None) or ((new_user is None) and (new_group is None)): raise utils.MuddleBug( "Either user/group or filespec is not specified in XML.") return ChangeUserInstruction(new_spec, new_user, new_group, self.name)
def clone_from_xml(self, xmlNode): """ Clone a filespec from some XML like:: <filespec> <root>..</root> <spec> ..</spec> <all-under /> <all-regex /> </filespec> """ if xmlNode.nodeName != "filespec": raise utils.GiveUp("Filespec xml node is called %s , not filespec." % (xmlNode.nodeName)) new_root = None new_spec = None new_all_under = False new_all_regex = False for c in xmlNode.childNodes: if c.nodeType == c.ELEMENT_NODE: if c.nodeName == "root": new_root = utils.text_in_node(c) elif c.nodeName == "spec": new_spec = utils.text_in_node(c) elif c.nodeName == "all-under": new_all_under = True elif c.nodeName == "all-regex": new_all_regex = True else: raise utils.GiveUp("Unknown element %s in filespec" % (c.nodeName)) return FileSpec(new_root, new_spec, new_all_under, new_all_regex)
def clone_from_xml(self, node): if (node.nodeType != node.ELEMENT_NODE or node.nodeName != "mknod"): raise utils.GiveUp("Invalid outer element for %s user instruction - %s"%("mknod", node)) result = MakeDeviceInstruction() for c in node.childNodes: if (c.nodeType == c.ELEMENT_NODE): if (c.nodeName == "name"): result.file_name = sanitise_filename(utils.text_in_node(c)) elif (c.nodeName == "uid"): result.uid = utils.text_in_node(c) elif (c.nodeName == "gid"): result.gid = utils.text_in_node(c) elif (c.nodeName == "type"): result.type = utils.text_in_node(c) elif (c.nodeName == "major"): result.major = utils.text_in_node(c) elif (c.nodeName == "minor"): result.minor = utils.text_in_node(c) elif (c.nodeName == "mode"): result.mode = utils.text_in_node(c) else: raise utils.GiveUp("Invalid node in mknod instruction: %s"%(c.nodeName)) result.validate() return result
def clone_from_xml(self, node): if (node.nodeType != node.ELEMENT_NODE or node.nodeName != "mknod"): raise utils.GiveUp( "Invalid outer element for %s user instruction - %s" % ("mknod", node)) result = MakeDeviceInstruction() for c in node.childNodes: if (c.nodeType == c.ELEMENT_NODE): if (c.nodeName == "name"): result.file_name = sanitise_filename(utils.text_in_node(c)) elif (c.nodeName == "uid"): result.uid = utils.text_in_node(c) elif (c.nodeName == "gid"): result.gid = utils.text_in_node(c) elif (c.nodeName == "type"): result.type = utils.text_in_node(c) elif (c.nodeName == "major"): result.major = utils.text_in_node(c) elif (c.nodeName == "minor"): result.minor = utils.text_in_node(c) elif (c.nodeName == "mode"): result.mode = utils.text_in_node(c) else: raise utils.GiveUp( "Invalid node in mknod instruction: %s" % (c.nodeName)) result.validate() return result
def clone_from_xml(self, xmlNode): """ Clone a filespec from some XML like:: <filespec> <root>..</root> <spec> ..</spec> <all-under /> <all-regex /> </filespec> """ if (xmlNode.nodeName != "filespec"): raise utils.GiveUp( "Filespec xml node is called %s , not filespec." % (xmlNode.nodeName)) new_root = None new_spec = None new_all_under = False new_all_regex = False for c in xmlNode.childNodes: if (c.nodeType == c.ELEMENT_NODE): if (c.nodeName == "root"): new_root = utils.text_in_node(c) elif (c.nodeName == "spec"): new_spec = utils.text_in_node(c) elif (c.nodeName == "all-under"): new_all_under = True elif (c.nodeName == "all-regex"): new_all_regex = True else: raise utils.GiveUp("Unknown element %s in filespec" % (c.nodeName)) return FileSpec(new_root, new_spec, new_all_under, new_all_regex)