def required_opts(opt, parser, opt_list, required_by=None):
    """Check that all the opts are defined

    Parameters
    ----------
    opt : object
        Result of option parsing
    parser : object
        OptionParser instance.
    opt_list : list of strings
    required_by : string, optional
        the option that requires these options (if applicable)
    """
    for name in opt_list:
        attr = name[2:].replace('-', '_')
        if not hasattr(opt, attr) or getattr(opt, attr) is None:
            err_str = '%s is missing ' % name
            if required_by is not None:
                err_str += ', required by %s' % required_by
            parser.error(err_str)
