

def catalog_downloads(url, fileFilter, fileNamer, fileDocumenter, klass):
    'returns dict of resources for downloading target data:\n    url: URL to a directory that gives links to the desired data\n    fileFilter: function that returns True for a desired file name\n    fileNamer: function that converts a file name into desired key value\n    fileDocumenter: function that returns a docstring based on file name\n    klass: a Python class or function that takes file URL as a single argument,\n           and returns value to store in dictionary\n\n    example usage:\n    d = catalog_downloads("http://biodb.bioinformatics.ucla.edu/PYGRDATA/",\n                          lambda x: x.endswith(".txt.gz"),\n                          lambda x: "Bio.MSA.UCSC."+x[:-3],\n                          SourceURL)\n    '
    import formatter
    import htmllib
    import urllib
    ifile = urllib.urlopen(url)
    try:
        p = htmllib.HTMLParser(formatter.NullFormatter())
        p.feed(ifile.read())
        l = p.anchorlist
    finally:
        ifile.close()
    d = {
        
    }
    if (url[(- 1)] != '/'):
        url += '/'
    for s in l:
        if fileFilter(s):
            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