@staticmethod
    def validate_type(value, type_name, force=False):
        is_ok = False
        if not force:
            if type_name=="any" or type_name=="void" or value is None: return
            clazz = type(value)
            if (type_name == "function"):
                is_ok = isinstance(value, types.FunctionType)
            elif type_name == "str":
                is_ok = isinstance(value, (six.text_type, six.string_types))
            elif (type_name in {"float", "int", "bool", "dict", "list"}):
                is_ok = type(value).__name__ == type_name
            else:
                p = type_name.split(".")
                if 1 < len(p):
                    c = p.pop()
                    m = __import__(".".join(p), fromlist=[c])
                    is_ok = isinstance(value, getattr(m, c))
                else:
                    c = globals()["__builtins__"][type_name]
                    is_ok = isinstance(value, c)
            
        if not is_ok:
            raise SaklientException("argument_type_mismatch", "Argument type mismatch (expected "+type_name+", got "+str(type(value))+")")
dataset/ETHPy150Open sakura-internet/saklient.python/saklient/util.py/Util.validate_type/original