def catalog_downloads(url, fileFilter, fileNamer, fileDocumenter, klass):
    '''returns dict of resources for downloading target data:
    url: URL to a directory that gives links to the desired data
    fileFilter: function that returns True for a desired file name
    fileNamer: function that converts a file name into desired key value
    fileDocumenter: function that returns a docstring based on file name
    klass: a Python class or function that takes file URL as a single argument,
           and returns value to store in dictionary

    example usage:
    d = catalog_downloads("http://biodb.bioinformatics.ucla.edu/PYGRDATA/",
                          lambda x: x.endswith(".txt.gz"),
                          lambda x: "Bio.MSA.UCSC."+x[:-3],
                          SourceURL)
    '''
    import formatter
    import htmllib
    import urllib
    #from BeautifulSoup import BeautifulSoup
    ifile = urllib.urlopen(url)
    try:
        p = htmllib.HTMLParser(formatter.NullFormatter())
        p.feed(ifile.read())
        l = p.anchorlist
        #soup = BeautifulSoup(ifile.read())
        # l = [str(a['href']) for a in soup.findAll('a')]
    finally:
        ifile.close()
    d = {}
    if url[-1] != '/': # make sure url ends in trailing /
        url += '/'
    for s in l: # find all anchors in the document
        if fileFilter(s): # save it
            o = klass(urllib.basejoin(url, s))
            o.__doc__ = fileDocumenter(s)
            d[fileNamer(s)] = o
    return d
dataset/ETHPy150Open cjlee112/pygr/pygr/apps/catalog_downloads.py/catalog_downloads/original