def cast_arg(t, val):
    """Attempts to call t on val, raising a ArgumentTypeError
    on ValueError.

    If 't' is the special string 'intbool', attempts to cast first
    to an int and then to a bool (i.e., 1=True, 0=False).
    """
    if t == 'intbool':
        return cast_arg(bool, cast_arg(int, val))
    else:
        try:
            return t(val)
        except __HOLE__:
            raise ArgumentTypeError()
dataset/ETHPy150Open beetbox/beets/beetsplug/bpd/__init__.py/cast_arg