human
Complete this python program:
def _process_extra_specs(extra_specs, resources):
assistant
#Here is the Python code you requested.

    """Check the flavor\s extra_specs for custom resource information.
    These will be a dict that is generated from the flavor; and in the
    flavor, the extra_specs entries will be in the format of either:
    resources:$CUSTOM_RESOURCE_CLASS=$N
    ...to add a custom resource class to the request, with a positive
    integer amount of $N
    resources:$STANDARD_RESOURCE_CLASS=0
    ...to remove that resource class from the request.
    resources:$STANDARD_RESOURCE_CLASS=$N
    ...to override the flavor\s value for that resource class with $N
    """
    resource_specs = {key.split('resources:', 1)[(-1)]: val for (key, val) in extra_specs.items() if key.startswith('resources:')}
    resource_keys = set(resource_specs)
    custom_keys = set([key for key in resource_keys if key.startswith(ResourceClass.CUSTOM_NAMESPACE)])
    std_keys = (resource_keys - custom_keys)
    def validate_int(key):
        val = resource_specs.get(key)
        try:
            return int(val)
        except ValueError:
            LOG.warning("Resource    amounts    must    be    integers.    Received    '%(val)s'    for    key    %(key)s.", {'key': key, 'val': val})
            return None
    for custom_key in custom_keys:
        custom_val = validate_int(custom_key)
        if (custom_val is not None):
            if (custom_val == 0):
                LOG.warning("Resource    amounts    must    be    positive    integers.    Received    '%(val)s'    for    key    %(key)s.", {'key': custom_key, 'val': custom_val})
                continue
            resources[custom_key] = custom_val
    for std_key in std_keys:
        if (std_key not in resources):
            LOG.warning("Received    an    invalid    ResourceClass    '%(key)s'    in    extra_specs.", {'key': std_key})
            continue
        val = validate_int(std_key)
        if (val is None):
            continue
        elif (val == 0):
            resources.pop(std_key, None)
        else:
            resources[std_key] = val