(
    obj_list,
    format,
    title,
    get_podcast=None,
    json_map=lambda x: x.url,
    jsonp_padding=None,
    xml_template=None,
    request=None,
    template_args={},
)
Formats a list of podcasts for use in a API response

    obj_list is a list of podcasts or objects that contain podcasts
    format is one if txt, opml or json
    title is a label of the list
    if obj_list is a list of objects containing podcasts, get_podcast is the
      function used to get the podcast out of the each of these objects
    json_map is a function returning the contents of an object (from obj_list)
      that should be contained in the result (only used for format='json')
Formats a list of podcasts for use in a API response
Formats a list of podcasts for use in a API response
def format_podcast_list(
    obj_list,
    format,
    title,
    get_podcast=None,
    json_map=lambda x: x.url,
    jsonp_padding=None,
    xml_template=None,
    request=None,
    template_args={},
):
    """
    Formats a list of podcasts for use in a API response

    obj_list is a list of podcasts or objects that contain podcasts
    format is one if txt, opml or json
    title is a label of the list
    if obj_list is a list of objects containing podcasts, get_podcast is the
      function used to get the podcast out of the each of these objects
    json_map is a function returning the contents of an object (from obj_list)
      that should be contained in the result (only used for format='json')
    """

    def default_get_podcast(p):
        return p

    get_podcast = get_podcast or default_get_podcast

    if format == "txt":
        podcasts = map(get_podcast, obj_list)
        s = "\n".join([p.url for p in podcasts] + [""])
        return HttpResponse(s, content_type="text/plain")

    elif format == "opml":
        podcasts = map(get_podcast, obj_list)
        exporter = Exporter(title)
        opml = exporter.generate(podcasts)
        return HttpResponse(opml, content_type="text/xml")

    elif format == "json":
        objs = list(map(json_map, obj_list))
        return JsonResponse(objs)

    elif format == "jsonp":
        ALLOWED_FUNCNAME = string.ascii_letters + string.digits + "_"

        if not jsonp_padding:
            return HttpResponseBadRequest(
                "For a JSONP response, specify the name of the callback function in the jsonp parameter"
            )

        if any(x not in ALLOWED_FUNCNAME for x in jsonp_padding):
            return HttpResponseBadRequest(
                "JSONP padding can only contain the characters %(char)s"
                % {"char": ALLOWED_FUNCNAME}
            )

        objs = list(map(json_map, obj_list))
        return JsonResponse(objs, jsonp_padding=jsonp_padding)

    elif format == "xml":
        if None in (xml_template, request):
            return HttpResponseBadRequest("XML is not a valid format for this request")

        podcasts = map(json_map, obj_list)
        template_args.update({"podcasts": podcasts})

        return render(
            request, xml_template, template_args, content_type="application/xml"
        )

    else:
        return None
def format_podcast_list ( obj_list , format , title , get_podcast = None , json_map = lambda x : x . url , jsonp_padding = None , xml_template = None , request = None , template_args = { } , ) : def default_get_podcast ( p ) : return p get_podcast = get_podcast or default_get_podcast if format == "txt" : podcasts = map ( get_podcast , obj_list ) s = "\n" . join ( [ p . url for p in podcasts ] + [ "" ] ) return HttpResponse ( s , content_type = "text/plain" ) elif format == "opml" : podcasts = map ( get_podcast , obj_list ) exporter = Exporter ( title ) opml = exporter . generate ( podcasts ) return HttpResponse ( opml , content_type = "text/xml" ) elif format == "json" : objs = list ( map ( json_map , obj_list ) ) return JsonResponse ( objs ) elif format == "jsonp" : ALLOWED_FUNCNAME = string . ascii_letters + string . digits + "_" if not jsonp_padding : return HttpResponseBadRequest ( "For a JSONP response, specify the name of the callback function in the jsonp parameter" ) if any ( x not in ALLOWED_FUNCNAME for x in jsonp_padding ) : return HttpResponseBadRequest ( "JSONP padding can only contain the characters %(char)s" % { "char" : ALLOWED_FUNCNAME } ) objs = list ( map ( json_map , obj_list ) ) return JsonResponse ( objs , jsonp_padding = jsonp_padding ) elif format == "xml" : if None in ( xml_template , request ) : return HttpResponseBadRequest ( "XML is not a valid format for this request" ) podcasts = map ( json_map , obj_list ) template_args . update ( { "podcasts" : podcasts } ) return render ( request , xml_template , template_args , content_type = "application/xml" ) else : return None