ietfparse/headers.py
def _parse_parameter_list(parameter_list,
                          normalized_parameter_values=_DEF_PARAM_VALUE,
                          normalize_parameter_names=False,
                          normalize_parameter_values=True):
    """
    Parse a named parameter list in the "common" format.

    :param parameter_list: sequence of string values to parse
    :keyword bool normalize_parameter_names: if specified and *truthy*
        then parameter names will be case-folded to lower case
    :keyword bool normalize_parameter_values: if omitted or specified
        as *truthy*, then parameter values are case-folded to lower case
    :keyword bool normalized_parameter_values: alternate way to spell
        ``normalize_parameter_values`` -- this one is deprecated
    :return: a sequence containing the name to value pairs

    The parsed values are normalized according to the keyword parameters
    and returned as :class:`tuple` of name to value pairs preserving the
    ordering from `parameter_list`.  The values will have quotes removed
    if they were present.

    """
    if normalized_parameter_values is not _DEF_PARAM_VALUE:  # pragma: no cover
        warnings.warn('normalized_parameter_values keyword to '
                      '_parse_parameter_list is deprecated, use '
                      'normalize_parameter_values instead',
                      DeprecationWarning)
        normalize_parameter_values = normalized_parameter_values
    parameters = []
    for param in parameter_list:
        param = param.strip()
        if param:
            name, value = param.split('=')
            if normalize_parameter_names:
                name = name.lower()
            if normalize_parameter_values:
                value = value.lower()
            parameters.append((name, _dequote(value.strip())))
    return parameters
def _parse_parameter_list(parameter_list,
                          normalized_parameter_values=_DEF_PARAM_VALUE,
                          normalize_parameter_names=False,
                          normalize_parameter_values=True):
    if normalized_parameter_values is not _DEF_PARAM_VALUE:  # pragma: no cover
        warnings.warn('normalized_parameter_values keyword to '
                      '_parse_parameter_list is deprecated, use '
                      'normalize_parameter_values instead',
                      DeprecationWarning)
        normalize_parameter_values = normalized_parameter_values
    parameters = []
    for param in parameter_list:
        param = param.strip()
        if param:
            name, value = param.split('=')
            if normalize_parameter_names:
                name = name.lower()
            if normalize_parameter_values:
                value = value.lower()
            parameters.append((name, _dequote(value.strip())))
    return parameters
def _parse_parameter_list ( parameter_list , normalized_parameter_values = _DEF_PARAM_VALUE , normalize_parameter_names = False , normalize_parameter_values = True ) : if normalized_parameter_values is not _DEF_PARAM_VALUE : # pragma: no cover warnings . warn ( 'normalized_parameter_values keyword to ' '_parse_parameter_list is deprecated, use ' 'normalize_parameter_values instead' , DeprecationWarning ) normalize_parameter_values = normalized_parameter_values parameters = [ ] for param in parameter_list : param = param . strip ( ) if param : name , value = param . split ( '=' ) if normalize_parameter_names : name = name . lower ( ) if normalize_parameter_values : value = value . lower ( ) parameters . append ( ( name , _dequote ( value . strip ( ) ) ) ) return parameters
Parse a named parameter list in the "common" format.

    :param parameter_list: sequence of string values to parse
    :keyword bool normalize_parameter_names: if specified and *truthy*
        then parameter names will be case-folded to lower case
    :keyword bool normalize_parameter_values: if omitted or specified
        as *truthy*, then parameter values are case-folded to lower case
    :keyword bool normalized_parameter_values: alternate way to spell
        ``normalize_parameter_values`` -- this one is deprecated
    :return: a sequence containing the name to value pairs

    The parsed values are normalized according to the keyword parameters
    and returned as :class:`tuple` of name to value pairs preserving the
    ordering from `parameter_list`.  The values will have quotes removed
    if they were present.
Parse a named parameter list in the common format .