def merge_options(options_class, base, kwargs):
    """
    Given an 'options_class', an optional 'base' object to copy from,
    and some keyword arguments, create a new options instance
    """
    if base is not None and not kwargs:
        return base
    retval = options_class()
    if base is not None:
        retval.__dict__.update(base.__dict__)
    kwarg_options = options_class(**kwargs)
    for k in kwargs.keys():
        setattr(retval, k, getattr(kwarg_options, k))
    return retval
