def set_text(self, val, base64encode=False):
        typ = self.get_type()
        if base64encode:
            import base64

            val = base64.encodestring(val)
            self.set_type("xs:base64Binary")
        else:
            if isinstance(val, basestring):
                if not typ:
                    self.set_type("xs:string")
                else:
                    try:
                        assert typ == "xs:string"
                    except AssertionError:
                        if typ == "xs:int":
                            _ = int(val)
                        elif typ == "xs:boolean":
                            if val.lower() not in ["true", "false"]:
                                raise ValueError("Not a boolean")
                        elif typ == "xs:float":
                            _ = float(val)
                        elif typ == "xs:base64Binary":
                            pass
                        else:
                            ValueError("Type and value doesn't match")
            elif isinstance(val, bool):
                if val:
                    val = "true"
                else:
                    val = "false"
                if not typ:
                    self.set_type("xs:boolean")
                else:
                    assert typ == "xs:boolean"
            elif isinstance(val, int):
                val = str(val)
                if not typ:
                    self.set_type("xs:integer")
                else:
                    assert typ == "xs:integer"
            elif isinstance(val, float):
                val = str(val)
                if not typ:
                    self.set_type("xs:float")
                else:
                    assert typ == "xs:float"
            elif not val:
                try:
                    self.extension_attributes[XSI_TYPE] = typ
                except __HOLE__:
                    self._extatt[XSI_TYPE] = typ
                val = ""
            else:
                if typ == "xs:anyType":
                    pass
                else:
                    raise ValueError

        SamlBase.__setattr__(self, "text", val)
        return self
dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/pysaml2-2.4.0/src/saml2/saml.py/AttributeValueBase.set_text