Example #1
0
 def saniOptionalLang(self, elem, attr, selem, default="en-EN"):
     if elem.get(attr) != None:
         lang = langCode(elem.get(attr))
         if lang.fullCheck() == True:
             selem.set(attr, elem.get(attr))
         else:
             selem.set(attr, default)
Example #2
0
    def checkOptionalLang(self, elem, attr):
        """
Handle a optional direct child attribute of type LANG. Compares the value of 
attr with the rules defined in RFC3066, Iana, Iso639 or Iso3166 specifications

elem is a ElementTree element instance
attr is the name of the optional attribute, string
        """
        if elem.get(attr) == None:
            self.mb.setMessage("notice", _(u"Element %s has no optional attribute %s") % (elem.tag, attr))
        else:
            self.mb.setMessage("notice", _(u"Element %s has optional attribute %s with value %s") % (elem.tag, attr, elem.get(attr)))
            lang = langCode(elem.get(attr))
            if lang.formalCheck() == True:
                self.mb.setMessage("notice", _(u"Value %s of attribute %s in element %s accords to RFC3066") % (elem.get(attr), attr, elem.tag))
                if lang.fullCheck() == True:
                    self.mb.setMessage("notice", _(u"Value %s of attribute %s in element %s accords to RFC3066, Iana, Iso639 or Iso3166 specifications") % (elem.get(attr), attr, elem.tag))
                else:
                    self.mb.setMessage("warning", _(u"Value %s of attribute %s in element %s does not accord to RFC3066, Iana, Iso639 or Iso3166 specifications") % (elem.get(attr), attr, elem.tag))
            else:
                self.mb.setMessage("error", _(u"Value %s of attribute %s in element %s does not accord to RFC3066") % (elem.get(attr), attr, elem.tag))
Example #3
0
    def checkOptionalLang(self, elem, attr):
        """
Handle a optional direct child attribute of type LANG. Compares the value of 
attr with the rules defined in RFC3066, Iana, Iso639 or Iso3166 specifications

elem is a ElementTree element instance
attr is the name of the optional attribute, string
        """
        if elem.get(attr) == None:
            self.mb.setMessage(
                "notice",
                _(u"Element %s has no optional attribute %s") %
                (elem.tag, attr))
        else:
            self.mb.setMessage(
                "notice",
                _(u"Element %s has optional attribute %s with value %s") %
                (elem.tag, attr, elem.get(attr)))
            lang = langCode(elem.get(attr))
            if lang.formalCheck() == True:
                self.mb.setMessage(
                    "notice",
                    _(u"Value %s of attribute %s in element %s accords to RFC3066"
                      ) % (elem.get(attr), attr, elem.tag))
                if lang.fullCheck() == True:
                    self.mb.setMessage(
                        "notice",
                        _(u"Value %s of attribute %s in element %s accords to RFC3066, Iana, Iso639 or Iso3166 specifications"
                          ) % (elem.get(attr), attr, elem.tag))
                else:
                    self.mb.setMessage(
                        "warning",
                        _(u"Value %s of attribute %s in element %s does not accord to RFC3066, Iana, Iso639 or Iso3166 specifications"
                          ) % (elem.get(attr), attr, elem.tag))
            else:
                self.mb.setMessage(
                    "error",
                    _(u"Value %s of attribute %s in element %s does not accord to RFC3066"
                      ) % (elem.get(attr), attr, elem.tag))