def parse_args(parser, args, enforce_requires=True):
    options, args = parser.parse_known_args(args or ['-h'])
    if enforce_requires and (options.debug or options.info):
        logging.getLogger("swiftclient")
        if options.debug:
            logging.basicConfig(level=logging.DEBUG)
            logging.getLogger('iso8601').setLevel(logging.WARNING)
            client_logger_settings['redact_sensitive_headers'] = False
        elif options.info:
            logging.basicConfig(level=logging.INFO)

    if args and options.help:
        _help = globals().get('st_%s_help' % args[0],
                              "no help for %s" % args[0])
        print(_help)
        exit()

    # Short circuit for tempurl, which doesn't need auth
    if args and args[0] == 'tempurl':
        return options, args

    if options.auth_version == '3.0':
        # tolerate sloppy auth_version
        options.auth_version = '3'

    if (not (options.auth and options.user and options.key)
            and options.auth_version != '3'):
        # Use keystone auth if any of the old-style args are missing
        options.auth_version = '2.0'

    # Use new-style args if old ones not present
    if not options.auth and options.os_auth_url:
        options.auth = options.os_auth_url
    if not options.user and options.os_username:
        options.user = options.os_username
    if not options.key and options.os_password:
        options.key = options.os_password

    # Specific OpenStack options
    options.os_options = {
        'user_id': options.os_user_id,
        'user_domain_id': options.os_user_domain_id,
        'user_domain_name': options.os_user_domain_name,
        'tenant_id': options.os_tenant_id,
        'tenant_name': options.os_tenant_name,
        'project_id': options.os_project_id,
        'project_name': options.os_project_name,
        'project_domain_id': options.os_project_domain_id,
        'project_domain_name': options.os_project_domain_name,
        'service_type': options.os_service_type,
        'endpoint_type': options.os_endpoint_type,
        'auth_token': options.os_auth_token,
        'object_storage_url': options.os_storage_url,
        'region_name': options.os_region_name,
    }

    if len(args) > 1 and args[0] == "capabilities":
        return options, args

    if (options.os_options.get('object_storage_url') and
            options.os_options.get('auth_token') and
            ('2.0', '3') in options.auth_version):
        return options, args

    if enforce_requires:
        if options.auth_version == '3':
            if not options.auth:
                exit('Auth version 3 requires OS_AUTH_URL to be set or ' +
                     'overridden with --os-auth-url')
            if not (options.user or options.os_user_id):
                exit('Auth version 3 requires either OS_USERNAME or ' +
                     'OS_USER_ID to be set or overridden with ' +
                     '--os-username or --os-user-id respectively.')
            if not options.key:
                exit('Auth version 3 requires OS_PASSWORD to be set or ' +
                     'overridden with --os-password')
        elif not (options.auth and options.user and options.key):
            exit('''
Auth version 1.0 requires ST_AUTH, ST_USER, and ST_KEY environment variables
to be set or overridden with -A, -U, or -K.

Auth version 2.0 requires OS_AUTH_URL, OS_USERNAME, OS_PASSWORD, and
OS_TENANT_NAME OS_TENANT_ID to be set or overridden with --os-auth-url,
--os-username, --os-password, --os-tenant-name or os-tenant-id. Note:
adding "-V 2" is necessary for this.'''.strip('\n'))
    return options, args
dataset/ETHPy150Open openstack/python-swiftclient/swiftclient/shell.py/parse_args/swapped operands of `in`