(raw_post_data, format)
return urls
Parses the data according to the format
Parses the data according to the format
Parses the data according to the format
def parse_subscription(raw_post_data, format):
    """Parses the data according to the format"""
    if format == "txt":
        urls = raw_post_data.split("\n")

    elif format == "opml":
        begin = raw_post_data.find("<?xml")
        end = raw_post_data.find("</opml>") + 7
        i = Importer(content=raw_post_data[begin:end])
        urls = [p["url"] for p in i.items]

    elif format == "json":
        begin = raw_post_data.find("[")
        end = raw_post_data.find("]") + 1
        urls = json.loads(raw_post_data[begin:end])

        if not isinstance(urls, list):
            raise ValueError("A list of feed URLs was expected")

    else:
        return []

    urls = filter(None, urls)
    urls = list(map(normalize_feed_url, urls))
    return urls
def parse_subscription ( raw_post_data , format ) : if format == "txt" : urls = raw_post_data . split ( "\n" ) elif format == "opml" : begin = raw_post_data . find ( "<?xml" ) end = raw_post_data . find ( "</opml>" ) + 7 i = Importer ( content = raw_post_data [ begin : end ] ) urls = [ p [ "url" ] for p in i . items ] elif format == "json" : begin = raw_post_data . find ( "[" ) end = raw_post_data . find ( "]" ) + 1 urls = json . loads ( raw_post_data [ begin : end ] ) if not isinstance ( urls , list ) : raise ValueError ( "A list of feed URLs was expected" ) else : return [ ] urls = filter ( None , urls ) urls = list ( map ( normalize_feed_url , urls ) ) return urls