def get_param_arg(param, idx, klass, arg, attr='id'):
    """Return the correct value for a fabric from `arg`."""
    if isinstance(arg, klass):
        return getattr(arg, attr)
    elif isinstance(arg, (int, str)):
        return arg
    else:
        raise TypeError('%s[%d] must be int, str, or %s, not %s' % (param,
            idx, klass.__name__, type(arg).__name__))
