def _make_w3c_caps(caps):
    """Makes a W3C alwaysMatch capabilities object.

    Filters out capability names that are not in the W3C spec. Spec-compliant
    drivers will reject requests containing unknown capability names.

    Moves the Firefox profile, if present, from the old location to the new Firefox
    options object.

    :Args:
     - caps - A dictionary of capabilities requested by the caller.
    """
    caps = copy.deepcopy(caps)
    profile = caps.get('firefox_profile')
    always_match = {}
    if caps.get('proxy') and caps['proxy'].get('proxyType'):
        caps['proxy']['proxyType'] = caps['proxy']['proxyType'].lower()
    for k, v in caps.items():
        if v and k in _OSS_W3C_CONVERSION:
            always_match[_OSS_W3C_CONVERSION[k]] = v.lower() if k == 'platform' else v
        if k in _W3C_CAPABILITY_NAMES or ':' in k:
            always_match[k] = v
    if profile:
        moz_opts = always_match.get('moz:firefoxOptions', {})
        # If it's already present, assume the caller did that intentionally.
        if 'profile' not in moz_opts:
            # Don't mutate the original capabilities.
            new_opts = copy.deepcopy(moz_opts)
            new_opts['profile'] = profile
            always_match['moz:firefoxOptions'] = new_opts
    return {"firstMatch": [{}], "alwaysMatch": always_match}
def _make_w3c_caps ( caps ) : caps = copy . deepcopy ( caps ) profile = caps . get ( 'firefox_profile' ) always_match = { } if caps . get ( 'proxy' ) and caps [ 'proxy' ] . get ( 'proxyType' ) : caps [ 'proxy' ] [ 'proxyType' ] = caps [ 'proxy' ] [ 'proxyType' ] . lower ( ) for k , v in caps . items ( ) : if v and k in _OSS_W3C_CONVERSION : always_match [ _OSS_W3C_CONVERSION [ k ] ] = v . lower ( ) if k == 'platform' else v if k in _W3C_CAPABILITY_NAMES or ':' in k : always_match [ k ] = v if profile : moz_opts = always_match . get ( 'moz:firefoxOptions' , { } ) if 'profile' not in moz_opts : new_opts = copy . deepcopy ( moz_opts ) new_opts [ 'profile' ] = profile always_match [ 'moz:firefoxOptions' ] = new_opts return { "firstMatch" : [ { } ] , "alwaysMatch" : always_match }
Makes a W3C alwaysMatch capabilities object.

    Filters out capability names that are not in the W3C spec. Spec-compliant
    drivers will reject requests containing unknown capability names.

    Moves the Firefox profile, if present, from the old location to the new Firefox
    options object.

    :Args:
     - caps - A dictionary of capabilities requested by the caller.