Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(1)  |  Call(0)  |  Derive(0)  |  Import(1)
Transform a header string of comma separated parameters into a dict

        def flat_header_val_to_dict(header_val):
    """
    Transform a header string of comma separated parameters into a dict
    """
    val_dict = {}
    val_comps = header_val.rsplit(',')
    if len(val_comps):
        for val_comp in val_comps:
            key, sep, val = val_comp.partition("=")
            if sep != "=":
                raise RequestHeaderException("non key/val entry in header")
            key = key.strip()
            val = val.strip()
            val = val.strip('"')
            if key in val_dict:
                if isinstance(val_dict[key], list):
                    val_dict[key].append(val)
                else:
                    val_dict[key] = [val_dict[key], val]
            else:
                val_dict[key] = val
    return val_dict
        


src/i/x/IXDjango-0.1.4/ixdjango/test_suite/utils.py   IXDjango(Download)
from django.http import HttpRequest, QueryDict
 
from ixdjango.utils import (
    random_string,
    querydict_to_dict,