def opts2dict(opts):
    """Converts options returned from an OptionParser into a dict"""
    ret = {}
    for k in dir(opts):
        if callable(getattr(opts, k)):
            continue
        if k.startswith('_'):
            continue
        ret[k] = getattr(opts, k)
    return ret