view mirror.py @ 4:d004395e7606

Oops, forgot to add index.js from the parchment svn repo.
author Atul Varma <varmaa@toolness.com>
date Tue, 27 May 2008 23:52:37 -0700
parents 27b872aee1a7
children fee2c6b5881d
line wrap: on
line source

import os
import cPickle
import urllib2
import distutils.dir_util

import generate_index

BASE_URL = "http://ifarchive.flavorplex.com"

if __name__ == "__main__":
    dicts = cPickle.load(open(generate_index.PICKLE_FILENAME, "r"))
    for info in dicts:
        path = info['path']
        if not os.path.exists(path):
            url = "%s/%s" % (BASE_URL, path)
            print "Fetching %s..." % url
            fileobj = urllib2.urlopen(url)
            contents = fileobj.read()
            distutils.dir_util.mkpath(os.path.dirname(path))
            open(path, "wb").write(contents)