def controller_validator(klass, obj):
    """
    Validates a handler implementation against the IController interface.

    """
    members = [
        '_setup',
        '_dispatch',
    ]
    meta = [
        'label',
        'interface',
        'config_section',
        'config_defaults',
        'stacked_on',
        'stacked_type',
    ]
    interface.validate(IController, obj, members, meta=meta)

    # also check _meta.arguments values
    errmsg = "Controller arguments must be a list of tuples.  I.e. " + \
             "[ (['-f', '--foo'], dict(action='store')), ]"

    if obj._meta.arguments is not None:
        if type(obj._meta.arguments) is not list:
            raise exc.InterfaceError(errmsg)
        for item in obj._meta.arguments:
            if type(item) is not tuple:
                raise exc.InterfaceError(errmsg)
            if type(item[0]) is not list:
                raise exc.InterfaceError(errmsg)
            if type(item[1]) is not dict:
                raise exc.InterfaceError(errmsg)

    if not obj._meta.label == 'base' and obj._meta.stacked_on is None:
        errmsg = "Controller `%s` is not stacked anywhere!" % \
                 obj.__class__.__name__
        raise exc.InterfaceError(errmsg)
    if not obj._meta.label == 'base' and \
            obj._meta.stacked_type not in ['nested', 'embedded']:
        raise exc.InterfaceError(
            obj._meta.label % "Controller '%s' " +
            "has an unknown stacked type of '%s'." %
            obj._meta.stacked_type
        )
dataset/ETHPy150Open datafolklabs/cement/cement/core/controller.py/controller_validator/swapped operands of `%`