def Warning(switch, defaulttip, defaultstate, before=False): """Returns a Warning switch object""" sw = "-gnatw" + switch return Check(sw, "-gnatw" + switch.upper(), Label(sw, defaulttip), Tip(sw, defaulttip), defaultstate, before)
def Validity(switch, defaulttip, defaultstate, before=False): """Returns a Validity Check switch object""" sw = "-gnatV" + switch return Check(sw, "-gnatV" + switch.upper(), Label(sw, defaulttip), Tip(sw, defaulttip), defaultstate, before)
def Style(switch, defaulttip, defaultstate, before=False): """Returns a Syle switch object""" sw = "-gnaty" + switch return Check(sw, "", Label(sw, defaulttip), Tip(sw, defaulttip), defaultstate, before)
def ReadXml(self, node): newname = str(node.getAttribute("name")) if newname != "": self.name = newname child = node.firstChild while child is not None: if child.nodeType == Node.ELEMENT_NODE: # if tip is not defined as attribute, it might be defined as a # child tip = str(child.getAttribute("tip")) if tip == "": children = child.getElementsByTagName("tip") if children.length == 1: tip = getText(children) # ??? Workaround issues in gnatcheck output I424-029 minval = child.getAttribute("min") maxval = child.getAttribute("max") defaultval = child.getAttribute("default") if minval == 1 and defaultval == 1: minval = 0 defaultval = 0 separator = child.getAttribute("separator") if separator == "": separator = ":" if child.localName == "category": newcat = Category("") newcat.ReadXml(child) self.AddCategory(newcat) elif child.localName == "check": self.AddRule( Check( str(child.getAttribute("switch")), re.sub("^[+]", "-", str(child.getAttribute("switch"))), str(child.getAttribute("label")), tip, False, False)) elif child.localName == "spin": self.AddRule( Spin( str(child.getAttribute("switch")), re.sub("^[+]", "-", str(child.getAttribute("switch"))), str(child.getAttribute("label")), tip, separator, defaultval, minval, maxval, False)) elif child.localName == "field": self.AddRule( Field(str(child.getAttribute("switch")), str(child.getAttribute("switch-off")), str(child.getAttribute("label")), tip, separator, defaultval, False)) elif child.localName == "combo": combo_ent = child.firstChild combo_entries = [] while combo_ent is not None: if combo_ent.nodeType == Node.ELEMENT_NODE: combo_entries.append( ComboEntry( value=str(combo_ent.getAttribute("value")), tip=str(combo_ent.getAttribute("tip")), label=str( combo_ent.getAttribute("label")))) combo_ent = combo_ent.nextSibling self.AddRule( Combo(switch=str(child.getAttribute("switch")), label=str(child.getAttribute("label")), tip=str(child.getAttribute("tip")), separator=separator, noswitch=str(child.getAttribute("noswitch")), values=combo_entries)) child = child.nextSibling